コード例 #1
0
        protected override string ComputeSignatureCore(string key, string data)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(data));

            using (var algorithm = KeyedHashAlgorithm.Create(SignatureMethod.ToUpperInvariant()))
            {
                algorithm.Key = _encoding.GetBytes(key.ToCharArray());
                return(Convert.ToBase64String(algorithm.ComputeHash(_encoding.GetBytes(data.ToCharArray()))));
            }
        }
        protected override string ComputeSignatureCore(string key, string data)
        {
            Debug.Assert(!string.IsNullOrEmpty(data));
#if NETCOREAPP2_0
            using (var algorithm = new HMACSHA1())
#else
            using (var algorithm = KeyedHashAlgorithm.Create(SignatureMethod.ToUpperInvariant()))
#endif
            {
                algorithm.Key = Encoding.GetBytes(key.ToCharArray());
                return(Convert.ToBase64String(
                           algorithm.ComputeHash(Encoding.GetBytes(data.ToCharArray()))));
            }
        }
コード例 #3
0
        protected override string ComputeSignatureCore(string key, string data)
        {
            Debug.Assert(!string.IsNullOrEmpty(data));

            using (var algorithm = CreateAlgorithm(SignatureMethod.ToUpperInvariant(), Encoding.GetBytes(key.ToCharArray())))
            {
                return(Convert.ToBase64String(algorithm.ComputeHash(Encoding.GetBytes(data.ToCharArray()))));
            }

            //using (var algorithm = KeyedHashAlgorithm.Create(SignatureMethod.ToUpperInvariant()))
            //{
            //    algorithm.Key = Encoding.GetBytes(key.ToCharArray());
            //    return Convert.ToBase64String(
            //        algorithm.ComputeHash(Encoding.GetBytes(data.ToCharArray())));
            //}
        }