我尝试使用 SHA256 对字符串进行哈希处理,我正在使用以下代码:
using System;
using System.Security.Cryptography;
using System.Text;
public class Hash
{
public static string getHashSha256(string text)
{
byte[] bytes = Encoding.Unicode.GetBytes(text);
SHA256Managed hashstring = new SHA256Managed();
byte[] hash = hashstring.ComputeHash(bytes);
string hashString = string.Empty;
foreach (byte x in hash)
{
hashString += String.Format("{0:x2}", x);
}
return hashString;
}
}
但是,与我的朋友 php 以及在线生成器(例如This generator)相比,此代码给出了明显不同的结果
有谁知道错误是什么?不同的基地?