Amazon.Util.CryptoUtilFactory.CryptoUtil.HMACSign C# (CSharp) Method

HMACSign() public method

public HMACSign ( byte data, string key, SigningAlgorithm algorithmName ) : string
data byte
key string
algorithmName SigningAlgorithm
return string
            public string HMACSign(byte[] data, string key, SigningAlgorithm algorithmName)
            {
                if (String.IsNullOrEmpty(key))
                    throw new ArgumentNullException("key", "Please specify a Secret Signing Key.");

                if (data == null || data.Length == 0)
                    throw new ArgumentNullException("data", "Please specify data to sign.");

                KeyedHashAlgorithm algorithm = ThreadSafeCreateKeyedHashedAlgorithm(algorithmName);

                if (null == algorithm)
                    throw new InvalidOperationException("Please specify a KeyedHashAlgorithm to use.");

                try
                {
                    algorithm.Key = Encoding.UTF8.GetBytes(key);
                    byte[] bytes = algorithm.ComputeHash(data);
                    return Convert.ToBase64String(bytes);
                }
                finally
                {
                    algorithm.Clear();
                }
            }

Same methods

CryptoUtilFactory.CryptoUtil::HMACSign ( string data, string key, SigningAlgorithm algorithmName ) : string