• C# HMACSHA256加密


    /// <summary>
    /// hmacsha256加密
    /// </summary>
    /// <param name="message">内容</param>
    /// <param name="secret">密钥</param>
    /// <param name="encoding">你懂的</param>
    /// <returns></returns>
    public static string HMACSHA256(string message, string secret, Encoding encoding)
    {
        byte[] keyByte = encoding.GetBytes(secret);
        byte[] messageBytes = encoding.GetBytes(message);
        using (var hmacsha256 = new HMACSHA256(keyByte))
        {
            byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
            return Convert.ToBase64String(hashmessage);
        }
    }
  • 相关阅读:
    20201107
    20201024
    20201020
    20200331
    20200330
    20200320
    20200319
    20200310
    20200221
    20190926
  • 原文地址:https://www.cnblogs.com/Transmuter/p/14918759.html
Copyright © 2020-2023  润新知