예제 #1
0
        /// <summary>获取HMAC-SHA256加密后的十六进制值
        /// </summary>
        /// <param name="source">字符串</param>
        /// <param name="key">密钥字符串</param>
        /// <param name="sourceEncode">编码</param>
        /// <param name="keyEncode">密钥编码</param>
        /// <returns>转换成16进制后的字符串</returns>
        public static string GetHex16StringHMACSHA256(string source, string key = "12345678", string sourceEncode = "utf-8", string keyEncode = "utf-8")
        {
            var hashBytes = GetHMACSHA256(Encoding.GetEncoding(sourceEncode).GetBytes(source), Encoding.GetEncoding(keyEncode).GetBytes(key));

            return(ByteBufferUtil.ByteBufferToHex16(hashBytes));
        }