Instance
MD5 Encryption "123456":
Hashbytes (' MD5 ', ' 123456 ')
Result: 0xe10adc3949ba59abbe56e057f20f883e (hint: After the end, the result is converted. )
Function
Function |
Describe |
return value |
Hashbytes |
Hashbytes (' encryption method ', ' value to encrypt ') Encryption mode = MD2 | MD4 | MD5 | SHA | SHA1 |
Return value type:varbinary(maximum 8000 bytes) |
Hints and Notes
123456 of MD5 have tools to know the result: e10adc3949ba59abbe56e057f20f883e
The result of the hashbytes is: The value of 0xe10adc3949ba59abbe56e057f20f883e,16, minus "0x" converted to lowercase value is exactly the same as the MD5 value, where another function is needed (sys.fn_ SQLVARBASETOSTR) Convert the value of varbinary to a varchar type, complete SQL is as follows:
Select substring (sys.fn_sqlvarbasetostr (hashbytes (' MD5 ', ' 123456 ')), 3,32)
The result is the complete MD5 value: e10adc3949ba59abbe56e057f20f883e
SQL Server built-in functions implement MD5 encryption