SQL Server built-in functions implement MD5 encryption

Source: Internet
Author: User
Tags md5 md5 encryption

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.