select cast(hashbytes('md5', 'test') as varchar)
displays
載쵫ⅆ珓�荎✦
but in C#,
System.Security.Cryptography.MD5.ComputeHash('test');
displays
c8059e2ec7419f590e79d7f1b774bfe6
which looks to be correct. Is this a problem with SQL Server's encoding?
hashbytes
is getting the raw MD5, while C# is returning the base-16 encoded version. (In fact, ComputeHash does the same thing -- you had to do some form of conversion to get it into that base 16 string, didn't you? :) )
精彩评论