Collections:
SHA2() - Calculating SHA-2 Hash
How to calculate a hash value of a byte string using the SHA2() function?
✍: FYIcenter.com
SHA2(str, len) is a MySQL built-in function that
calculates a hash value of a given byte string using the
SHA-2 (Secure Hash Algorithm 2) family of algorithms
(SHA-224, SHA-256, SHA-384, and SHA-512).
For example:
SELECT SHA2('abc', 256); SELECT SHA2('FYI', 256);
-- +------------------------------------------------------------------+
-- | SHA2('FYI', 256) |
-- +------------------------------------------------------------------+
-- | 3050d21d6aa694b99a7fc48eb57d390b64d64543e0ee9c78aadec620ad81fc73 |
-- +------------------------------------------------------------------+
SELECT SHA2('FYIcenter.com', 256);
-- +------------------------------------------------------------------+
-- | SHA2('FYIcenter.com', 256) |
-- +------------------------------------------------------------------+
-- | 9b3b41aa6093ec4c463697ac4fa0e71c88528346c22bf173bda806e5ceb799cd |
-- +------------------------------------------------------------------+
SELECT SHA2('FYIcenter.com', 384);
-- +--------------------------------------------------------------------------------------------------+
-- | SHA2('FYIcenter.com', 384) |
-- +--------------------------------------------------------------------------------------------------+
-- | 485ce34c0cfc9fb150d27ce56f38f656cb994f3ace97670b3937758816e8506761b3c73ef6bee2963a5296a2b877e4cf |
-- +--------------------------------------------------------------------------------------------------+
Reference information of the SHA2() function:
SHA2(str, len): hash Calculates a hash value of a given byte string using the SHA-2 algorithm. Arguments, return value and availability: str: Required. The byte string to be processed. len: Required. The number of bits of the resulting hash. hash: Return value. The SHA1 hash value in hexadecimal digits Available since MySQL 4.1.
Related MySQL functions:
⇒ STATEMENT_DIGEST() - Statement Digest Hash
⇐ SHA1() - Calculating SHA-1 Hash
2023-12-14, 1712🔥, 0💬
Popular Posts:
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Start Instance with a Minimal Initialization Parameter File in Oracle? The sample initializat...
How to change the data type of an existing column with "ALTER TABLE" statements in SQL Server? Somet...