If I use the string "password" in C # using SHA256 using the method below, I get this as my output:
e201065d0554652615c320c00a1d5bc8edca469d72c2790e24152d0c1e2b6189
But this website (SHA-256 creates a 256-bit (32-byte) hash value) tells me:
5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
I obviously have a problem with the data format or something similar. Any ideas why this C # SHA256Managed method returns something else? I am sending the password method as an input parameter.
private static string CalculateSHA256Hash(string text) { UnicodeEncoding UE = new UnicodeEncoding(); byte[] hashValue; byte[] message = UE.GetBytes(text); SHA256Managed hashString = new SHA256Managed(); string hex = ""; hashValue = hashString.ComputeHash(message); foreach (byte x in hashValue) { hex += String.Format("{0:x2}", x); } return hex; }
source share