2

I have a column of type nvarchar. I would like to get a SHA256 hash of the UTF32 representation of these characters.

I have found HASHBYTES which seems to do the meat of what I want to do, with SELECT HASHBYTES('SHA2_256', MyBinaryData).

It also indicates it can operate on nvarchar, but it doesn't indicate how it does the conversion from characters to bytes. I particularly need the hash of the UTF32 representation. How can I get that hash? Is there an in-database way to encode the nvarchar to UTF32 that I can feed to HASHBYTES? Is there another way?

Martijn
  • 11,964
  • 12
  • 50
  • 96

1 Answers1

0

To get the UTF32 representation of a nvarchar column (in SQL Server) you should use some CLR code.

Try something similar to the code in this answer: https://stackoverflow.com/a/14041069/1187211

Razvan Socol
  • 5,426
  • 2
  • 20
  • 32