C# 实现SHA256加密

需要依赖mscorlib.dll

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

            return builder.ToString();
        }

你可能感兴趣的:(c#,哈希算法,开发语言)