PHP: sha1() function
PHP: Calculate the sha1 hash of a string
The sha1() function is used to calculate the sha1 hash of a string.
Version:
(PHP 4 and above)
Syntax:
sha1(string1, raw_output)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
string1 | The input string. | Required | String |
raw_output | If TRUE sets raw 20 characters binary format. If FALSE (default) sets raw 40 character hex number format. | Optional | Boolean |
Return value:
Returns the sha1 hash as a string.
Value Type: String.
Example:
<?php
$str = 'Good Morning';
echo sha1($str).'<br>';
echo sha1($str,TRUE).'<br>';
?>
Output:
06e336231466d0b0573a05cbca7813444afb5b29 ã6#fаW:ËÊxDJû[)
View the example in the browser
See also
Previous: sha1_file
Next: similar_text
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/sha1.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics