System.Security.Cryptography.IncrementalHash.CreateHMAC C# (CSharp) Method

CreateHMAC() public static method

Create an IncrementalHash for the Hash-based Message Authentication Code (HMAC) algorithm utilizing the hash algorithm specified by hashAlgorithm, and a key specified by key.
/// . is null, or /// the empty string. /// is not a known hash algorithm.
public static CreateHMAC ( HashAlgorithmName hashAlgorithm, byte key ) : IncrementalHash
hashAlgorithm HashAlgorithmName The name of the hash algorithm to perform within the HMAC.
key byte /// The secret key for the HMAC. The key can be any length, but a key longer than the output size /// of the hash algorithm specified by will be hashed (using the /// algorithm specified by ) to derive a correctly-sized key. Therefore, /// the recommended size of the secret key is the output size of the hash specified by /// . ///
return IncrementalHash
        public static IncrementalHash CreateHMAC(HashAlgorithmName hashAlgorithm, byte[] key)
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));
            if (string.IsNullOrEmpty(hashAlgorithm.Name))
                throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));

            return new IncrementalHash(hashAlgorithm, GetHMAC(hashAlgorithm, key));
        }