Collections:
SHA1() - Calculating SHA-1 Hash
How to calculate a hash value of a byte string using the SHA1() function?
✍: FYIcenter.com
SHA1(str) is a MySQL built-in function that
calculates a hash value of a given byte string using the SHA-1 (Secure Hash Algorithm 1) algorithm.
It always returns a 40 hexadecimal digits string presenting a 160-bit (20-byte) hash value.
For example:
SELECT SHA1('FYI'), LENGTH(SHA1('FYI')) AS Chars,
LENGTH(UNHEX(SHA1('FYI'))) AS Bytes;
-- +------------------------------------------+-------+-------+
-- | SHA1('FYI') | Chars | Bytes |
-- +------------------------------------------+-------+-------+
-- | d643c217544e8bb47f522201f71ec7d7905e5fa4 | 40 | 20 |
-- +------------------------------------------+-------+-------+
SELECT SHA1('FYIcenter.com'), LENGTH(SHA1('FYIcenter.com')) AS Chars,
LENGTH(UNHEX(SHA1('FYIcenter.com'))) AS Bytes;
-- +------------------------------------------+-------+-------+
-- | SHA1('FYIcenter.com') | Chars | Bytes |
-- +------------------------------------------+-------+-------+
-- | fdac19d0abac5ae6098fd0f5a433f09e2f60ee26 | 40 | 20 |
-- +------------------------------------------+-------+-------+
Reference information of the SHA1() function:
SHA1(str): hash Calculates a hash value of a given byte string using the SHA-1 algorithm. Arguments, return value and availability: str: Required. The byte string to be processed. hash: Return value. The SHA-1 hash value in hexadecimal digits Available since MySQL 4.1.
Related MySQL functions:
⇒ SHA2() - Calculating SHA-2 Hash
2023-12-14, 1062🔥, 0💬
Popular Posts:
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
What are single-byte character string data types supported in SQL Server Transact-SQL? Single-byte c...
How to set database to be READ_ONLY in SQL Server? Databases in SQL Server have two update options: ...
What Happens to Your Transactions When ERROR 1205 Occurred in MySQL? If your transaction receives th...
How To Calculate DATETIME Value Differences Using the DATEDIFF() Function in SQL Server Transact-SQL...