Example #1
0
        public static byte[] Compute(string data, string key)
        {
            return(HMAC.Compute(data, key, "HMac/SHA1"));

            //or
            //return HMAC.Compute(data, key, new Sha1Digest());
        }
Example #2
0
        public static byte[] Compute(string data, string key)
        {
            return(HMAC.Compute(data, key, "HMAC-MD5"));

            //or
            return(HMAC.Compute(data, key, new MD5Digest()));
        }
        /// <summary>
        /// 哈希计算(使用BouncyCastle)
        /// </summary>
        public static byte[] Compute(string data, byte[] key)
        {
            return(HMAC.Compute(data, key, Algorithms.HMacSHA256));

            //or
            //return HMAC.Compute(data, key, new Sha256Digest());
        }