📜  c# 字符串到 sha256 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:03.435000             🧑  作者: Mango

代码示例1
public static String sha256_hash(String value) {
  StringBuilder Sb = new StringBuilder();

  using (SHA256 hash = SHA256Managed.Create()) {
    Encoding enc = Encoding.UTF8;
    Byte[] result = hash.ComputeHash(enc.GetBytes(value));

    foreach (Byte b in result)
      Sb.Append(b.ToString("x2"));
  }

  return Sb.ToString();
}