我有一个使用 stringbuilder 构建的 C# 字符串。有 2 行有输出:
Line1
Line2
我用这段代码进行哈希:
public static string GetSha256Hash(string input)
{
using (SHA256 sha256Hash = SHA256.Create())
{
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
return Convert.ToBase64String(bytes);
}
}
CSPLite 创建正确的以下哈希:
然而,.net(下面是 C# 或 VB.Net)会创建不同的哈希值,因为换行符的处理方式可能不同
如果我复制并粘贴同一字符串的output,那么我会得到正确的哈希值
如何调整 C# 字符串以创建与 CSP 创建的哈希值相同的哈希值?
空白可能存在差异。尾随换行符或一个将换行符视为 另一个作为 和 .