Create() 공개 정적인 메소드

public static Create ( ) : HMAC
리턴 HMAC
예제 #1
0
        /// <summary>
        /// HMAC Hash
        /// </summary>
        /// <param name="algorithmName">HMACMD5, HMACSHA1, HMACSHA256, HMACSHA512 ...</param>
        /// <param name="key"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static byte[] HMAC(string algorithmName, string key, string text)
        {
            ThrowHelper.ThrowIfNull(algorithmName, "algorithmName");
            ThrowHelper.ThrowIfNull(key, "key");
            ThrowHelper.ThrowIfNull(text, "text");

            var bKey   = UTF8Encoding.GetBytes(key);
            var buffer = UTF8Encoding.GetBytes(text);

            using (var hashAlgorithm = HMACCrypt.Create(algorithmName))
            {
                hashAlgorithm.Key = bKey;
                return(hashAlgorithm.ComputeHash(buffer));
            }
        }
예제 #2
0
        // initializes the state of the operation.
        private void Initialize()
        {
            if (_buffer != null)
            {
                Array.Clear(_buffer, 0, _buffer.Length);
            }

            _hmac       = HMAC.Create(_hashName);
            _hmac.Key   = (byte[])_password.Clone();
            _blockSize  = _hmac.HashSize / 8;
            _buffer     = new byte[_blockSize];
            _block      = 1;
            _startIndex = _endIndex = 0;
            _state      = 0;
        }
예제 #3
0
 /// <summary>Creates an instance of the default implementation of a Hash-based Message Authentication Code (HMAC).</summary>
 /// <returns>A new SHA-1 instance, unless the default settings have been changed by using the &lt;cryptoClass&gt; element.</returns>
 // Token: 0x060021B3 RID: 8627 RVA: 0x000774EA File Offset: 0x000756EA
 public new static HMAC Create()
 {
     return(HMAC.Create("System.Security.Cryptography.HMAC"));
 }