English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP sha1() Function Usage and Example

PHP String Character String Functions Manual

sha1() function is used to calculate the sha of the string1 Hash Value.

Syntax

string sha1 ( string $str[, bool $raw_output = false ] )

Definition and Usage

Used to calculate the sha of the string1 Hash Value.

Return Value

It returns the sha1 Hash Value.

Parameter

Serial NumberParameters and Description
1

str (required)

Input string.

2

raw_output

Optional. If the raw_output parameter is set to TRUE, then sha1 The digest will be 20 character length raw format returned, otherwise the return value is a 40 character length hexadecimal number

Online Example

Try the following example, calculate the URL string "oldtoolbag.com" hash value:

<?php
   //Calculate the URL string "oldtoolbag.com" hash value:
   $input = "oldtoolbag.com";
   echo sha1($input);
?>
Test and see‹/›

Output Result

4ba7014d345010557e9ac4ed7d8c3e1c6b1e3d36

PHP String Character String Functions Manual