Javatpoint Logo
Javatpoint Logo

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.


Parameter Description Required/Optional
String Specify string to be calculated. required
raw Specify hex or binary output format:
  • TRUE - Raw 20 character binary format
  • FALSE - Default. 40 character hex number

Warning: It not recommended to use sha1 function to secure passwords, due to the fast nature of this hashing algorithm.

Example 1


Your string isHello PHP

Example 2


The string: Hello PHP
TRUE - Raw 20 character binary format: ?.&lo:???%P((???y?R
FALSE - 40 character hex number: a02e266c6f3a8ff0c4250e502828c4ebf179d252

Next TopicPHP String

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA