Introduction
In this Blog we will see how to convert string into MD5 in SQL Server. First we will try to understand what MD5 is.
The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.
Go to SQL Server and write the below SQL Query.
- Select CONVERT(VARCHAR(32), HashBytes('MD5', 'This text is going to be converted to MD5'), 2) as MD5Hash
Execute the preceding command and check the output.
![]()
So the MD5 equivalent of “This text is going to be converted to MD5
” is “4DF5BE7CB28FF963C57D51E6D3CCE042”.
Let’s try out one more examples. Execute the following command.
- Select CONVERT(VARCHAR(32), HashBytes('MD5', 'Sample Text'), 2) as MD5Hash
![]()
The MD5 equivalent of “Sample Text” is “83936A3F80BA44C78C9911F5445F2994”.