PHP sha1() Function

Calculates the sha1 hash of str using the ยป US Secure Hash Algorithm 1.

The sha1() function calculates the SHA-1 hash of a string.

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

The sha1() function uses the US Secure Hash Algorithm 1.

From RFC 3174 - The US Secure Hash Algorithm 1: "SHA-1 produces a 160-bit output called a message digest. The message digest can then, for example, be input to a signature algorithm which generates or verifies the signature for the message. Signing the message digest rather than the message often improves the efficiency of the process because the message digest is usually much smaller in size than the message. The same hash algorithm must be used by the verifier of a digital signature as was used by the creator of the digital signature."

Example -

ParameterDescription
strThe input string.
raw_outputIf the optional raw_output is set to TRUE, then the sha1 digest is instead returned in raw binary format with a length of 20, otherwise the returned value is a 40-character hexadecimal number.

Returns the sha1 hash as a string.