Using this code on the JavaScript side and
Using sha As New SHA256Managed
Using memStream As New MemoryStream(Encoding.ASCII.GetBytes("Hello World!"))
Dim hash() As Byte = sha.ComputeHash(memStream)
Dim res As String = Encoding.Default.GetString(hash)
End Using
End Using
I have been unable to recreate the same hash for the same values with these two bits of code.
The JavaScript implementation returns 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069
, and the VB.NET example returns ƒ±eñüS¹-ÁH¡Ö]ü-K£Öw(JÝÒ mi"
.
What am I missing? I assume it's something to do with the character encoding?
Solution: it was one simple change:
Using sha As New SHA256Managed
Using memStream As New MemoryStream(Encoding.ASCII.GetBytes("Hello World!"))
Dim hash() As Byte = sha.ComputeHash(memStream)
Dim res As String = BitConverter.ToString(hash)
End Using
End Using