c# .net sha256 16进制 64位 签名

public static string GetSHA256hash(string input, string _input_charset)
        {
             

            byte[] clearBytes = Encoding.UTF8.GetBytes(input);
            SHA256 sha256 = new SHA256Managed();
            sha256.ComputeHash(clearBytes);
            byte[] hashedBytes = sha256.Hash;
            sha256.Clear();
            string output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();

            return output;
        }

先用SHA256Managed计算HASH,然后用BitConverter.ToString转为16进制字符串。这个字符串REPLACE掉“-”后长度为64.

要不要REPLACE,和TOLOWER,看签名要求。

原文地址:https://www.cnblogs.com/runliuv/p/5088787.html