Forum Moderators: open
Public Function EncryptSHA256Managed2(ByVal ClearString As String) As String
Dim uEncode as New UnicodeEncoding()
Dim bytClearString() as Byte=uEncode.GetBytes(ClearString)
Dim sha as New System.Security.Cryptography.SHA256Managed()
Dim hash() as Byte = sha.ComputeHash(bytClearString)
Return Convert.ToBase64String(hash)
End Function
Public Function EncryptSHA256Managed(ByVal ClearString As String) As String
Dim arrHashInput As Byte()
Dim arrHashOutput As Byte()
Dim objSHA As SHA256Managed
objSHA = New SHA256Managed
arrHashInput = Convert2ByteArray(ClearString)
arrHashOutput = objSHA.ComputeHash(arrHashInput)
Return(BitConverter.ToString(arrHashOutput))
End Function
However this doesn't return the correct length of the string (either of these functions). I am expecting a string of 64 characters. The original asp application has a sha 256 function which returns this length? so what am I doing wrong?