I'm working on a C# project where we have a text value that is placed in a SQL Server database table in a nvarchar field. The value is hashed using the code below:
byte[] data = Encoding.ASCII.GetBytes("valuetohash");
byte[] bytes = new SHA512Managed().ComputeHash(data);
String result = Encoding.ASCII.GetString(bytes);
Now I need to duplicate creating that same value using T-SQL.
Can someone tell me how I can do that?
I tried HASHBYTES ( 'SHA2_512', 'valuetohash' )
but that lacks the ASCII encoding and produces a different value.