MySQL SHA1() Function
The MySQL SHA1() function returns an SHA-1 160-bit checksum representation of a given string. This function returns a 40 character hex string as the result. The result from this function can be used as a hash key.
The SHA1() function returns NULL if the string is NULL.
The SHA1() is a synonym for the SHA() function.
Syntax
SHA1(string)
Parameters
string |
Required. Specify the plaintext string used to generate the SHA-1 160-bit checksum. |
Return Value
Returns the SHA-1 160-bit checksum representation of a string.
Example:
The example below shows the usage of SHA1() function.
mysql> SELECT SHA1('xyz'); Result: '66b27417d37e024c46526c2f6d358a754fc552f3' mysql> SELECT SHA1('password'); Result: '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8' mysql> SELECT SHA1('alphacodingskills'); Result: '910c3491e62f9d1892600290990b1690a08eb045' mysql> SELECT SHA1(123); Result: '40bd001563085fc35165329ea1ff5c5ecbdbbeef' mysql> SELECT SHA1(NULL); Result: NULL
❮ MySQL Functions