开发者

Why is SQL Server 2008 MD5 displaying foreign characters? [duplicate]

This question already has answers here: 开发者_JAVA技巧 Convert HashBytes to VarChar (7 answers) Closed 7 years ago.
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? :) )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜