C# sha256加密算法

加密eg:

增加引用:using System.Security.Cryptography;

public string sha256(string data)
{
   byte[] bytes = Encoding.UTF8.GetBytes(data);
   byte[] hash = SHA256Managed.Create().ComputeHash(bytes);
 
   StringBuilder builder = new StringBuilder();
   for (int i = 0; i < hash.Length; i++)
   {
          builder.Append(hash[i].ToString("X2"));
   }
 
   return builder.ToString();
}

  

猜你喜欢

转载自www.cnblogs.com/chenze-Index/p/11751698.html
今日推荐