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