85
PHP string sha1() Function
PHP string sha1() is predefined function.It is used to calculate the SHA-1 hash of a string. It uses US secure Hash Algorithm 1. SHA-1 produces a 160-bit output called a message digest.
Note: To calculate the SHA-1 hash of a file, use the sha1_file()function.
Syntax:
Parameter | Description | Required/Optional |
---|---|---|
String | Specify string to be calculated. | required |
raw | Specify hex or binary output format:
| optional |
Warning: It not recommended to use sha1 function to secure passwords, due to the fast nature of this hashing algorithm.
Example 1
Output:
Your string isHello PHP a02e266c6f3a8ff0c4250e502828c4ebf179d252
Example 2
Output:
The string: Hello PHP TRUE - Raw 20 character binary format: ?.&lo:???%P((???y?R FALSE - 40 character hex number: a02e266c6f3a8ff0c4250e502828c4ebf179d252
Next TopicPHP String