Exemple #1
0
        /// <summary>
        /// 获取十六进制字符串的SHA512-Hash
        /// </summary>
        /// <param name="source">字符串</param>
        /// <param name="encode">编码</param>
        /// <returns></returns>
        public static string GetHex16StringSHA512Hash(string source, string encode = "utf-8")
        {
            var sourceBytes = Encoding.GetEncoding(encode).GetBytes(source);
            var hashBytes   = GetSHA512Hash(sourceBytes);

            return(ByteBufferUtil.ByteBufferToHex16(hashBytes));
        }
Exemple #2
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));
        }