64个字节是相同的,但==返回false.我猜测编码可能有问题,但我无法弄清楚我做错了什么.有什么想法解决这个问题?
public static byte[] hashSHA512(string unhashedValue)
{
SHA512 shaM = new SHA512Managed();
byte[] hash = shaM.ComputeHash(Encoding.UTF8.GetBytes(unhashedValue));
return hash;
}
public static bool Validate(string enteredValue, byte[] hashedValue)
{
byte[] hash = hashSHA512 (enteredValue);
return (hash == hashedValue);
}
Run Code Online (Sandbox Code Playgroud)
我用一个简单的值来测试它,因为它们都调用相同的哈希方法,所以除了编码中的某些东西之外我没有看到它如何失败.我只是使用内置的System.Security.Cryptography.
c# ×1