Esempio n. 1
0
        /// <summary>
        /// Get HMAC hasher.
        /// </summary>
        /// <param name="algorithm">HMAC algorithm</param>
        /// <returns></returns>
        public static IHmacHasher CreateHmacHasher(HashAlgorithm algorithm)
        {
            CheckCryptoProvider();
            ValidateHashAlgorithm(algorithm);

            if (algorithm.HasDeprecatedSinceDate)
            {
                throw new HashingException(string.Format("Hash algorithm {0} is deprecated since {1} and can not be used for HMAC.", algorithm.Name,
                                                         algorithm.DeprecatedSinceDate?.ToString(Constants.DateFormat)));
            }

            return(_cryptoProvider.CreateHmacHasher(algorithm));
        }