C# sha256 加密算法

C# 非对称加密

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();
}

 

posted @ 2018-11-19 17:37  代码沉思者  阅读(12740)  评论(0编辑  收藏  举报