MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB SHA() Function



The MariaDB SHA() 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 SHA() function returns NULL if the string is NULL.

The SHA() is a synonym for the SHA1() function.

Syntax

SHA(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 SHA() function.

SELECT SHA('xyz');
Result: '66b27417d37e024c46526c2f6d358a754fc552f3'

SELECT SHA('password');
Result: '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'

SELECT SHA('alphacodingskills');
Result: '910c3491e62f9d1892600290990b1690a08eb045'

SELECT SHA(123);
Result: '40bd001563085fc35165329ea1ff5c5ecbdbbeef'

SELECT SHA(NULL);
Result: NULL

❮ MariaDB Functions

5