【发布时间】:2018-07-16 15:28:38
【问题描述】:
我创建了哈希。比我在控制台中打印它。复制哈希值并将其放入代码进行比较。但这会导致它们不一样。
String input = "Hello";
String key = "Key";
Byte[] hashKey = Encoding.UTF8.GetBytes(key);
HMACSHA1 hmac = new HMACSHA1(hashKey);
Byte[] computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(input));
String computedHashString = Encoding.UTF8.GetString(computedHash);
Console.WriteLine("Hash value of your input: .{0}.", computedHashString);
if ("↨:?☼??W?u$YLR;?←?T?j" == computedHashString)
{
Console.WriteLine("They are same!");
}
else
{
Console.WriteLine("They are NOT same!");
}
Console.ReadLine();
提前谢谢你
【问题讨论】:
标签: c# encryption hash cryptography