SQL Server built-in functions implement MD5 encryption

Source: Internet
Author: User
Tags md5 encryption

Original: SQL Server built-in function implements 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 (sys) is required. 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,+)

The result is the complete MD5 value: e10adc3949ba59abbe56e057f20f883e

At last

Since the choice of distance, it is only the trials and tribulations, since the goal is the horizon, leaving the world can only be back.

Hope to work with our compatriots, to find fun in the job, in order to live, for ourselves, refueling!

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.