MD5 encryption used by SQL Server requires attention to instructions

Source: Internet
Author: User
Tags md5 encryption

It is common to use MD5 encryption in SQL, but it is not known that people who pay attention to it will be wrong even if they are writing on a copy network.

For example, a simple explanation:

We can find the same string but the resulting MD5 characters are not the same, then this time will be tangled up where the problem arises.

Look at the problem we're explaining:

The final discovery is the type of problem we define.

I'll post the code for everyone to use.

PRINT ' correct: ' + substring (sys.fn_sqlvarbasetostr (hashbytes (' MD5 ', ' _users01123456 ')), 3,32)
DECLARE @Name varchar (200);
DECLARE @Pwd varchar (100);
--User name
Set @Name = ' _users01 ';
Set @Pwd =convert (nvarchar, (@Name + ' 123456 '));
PRINT ' stitching up a good string: ' [email protected]
PRINT ' wrong: ' + substring (sys.fn_sqlvarbasetostr (hashbytes (' MD5 ', @Pwd)), 3,32)

Reminder: nvarchar, varchar in the choice of use when the best study ha, or more is a tear

MD5 encryption used by SQL Server requires attention to instructions

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.