String & Binary Functions (Checksum)


Returns a 16-byte BINARY value containing the 128-bit MD5 message digest.





A string expression, the message to be hashed.


Returns a 16-byte BINARY value containing the MD5 message digest.

Usage Notes

Although the MD5, MD5_BINARY, and MD5_NUMBER functions were originally developed as cryptographic functions, they are now obsolete for cryptography and should not be used for that purpose. They can be used for other purposes, for example as “checksum” functions to detect accidental data corruption.


The example below shows a simple example of using the function. Note that although the output is a 16-byte binary string, by default SNOWSQL displays binary values as a series of hexadecimal digits, so the output below appears as 32 hexadecimal digits, not as 16 one-byte characters.

SELECT md5_binary('Snowflake');
| MD5_BINARY('SNOWFLAKE')          |
| EDF1439075A83A447FB8B630DDC9C8DE |

This example demonstrates using the function to insert into a table that contains a column of type BINARY.

Create and fill a table:

CREATE TABLE binary_demo (b BINARY);
INSERT INTO binary_demo (b) SELECT MD5_BINARY('Snowflake');

Output when we retrieve the value:

SELECT TO_VARCHAR(b, 'HEX') AS hex_representation
    FROM binary_demo;
| HEX_REPRESENTATION               |
| EDF1439075A83A447FB8B630DDC9C8DE |