Convert HashBytes to VarChar

前端 未结 7 727
南旧
南旧 2020-12-07 10:08

I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command:

SELECT HashBytes(\'MD5\', \'HelloWorld\')
相关标签:
7条回答
  • 2020-12-07 11:00
    convert(varchar(34), HASHBYTES('MD5','Hello World'),1)
    

    (1 for converting hexadecimal to string)

    convert this to lower and remove 0x from the start of the string by substring:

    substring(lower(convert(varchar(34), HASHBYTES('MD5','Hello World'),1)),3,32)
    

    exactly the same as what we get in C# after converting bytes to string

    0 讨论(0)
提交回复
热议问题