public class Sha256Encrypt
{
/// <summary>
/// 使用Sha256算法加密字符串
/// </summary>
/// <param name="rawString"></param>
/// <returns></returns>
public static string Sha256(string rawString)
{
byte[] bytes = Encoding.UTF8.GetBytes(rawString);
byte[] hash = SHA256.Create().ComputeHash(bytes);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
builder.Append(hash[i].ToString("X2"));
}
return builder.ToString().ToLower();
}
}
Sha256加密字符串
于 2023-06-13 15:24:58 首次发布