Esempio n. 1
0
        /// <summary>
        /// Initialize the class and working variables.
        /// <para>When this constructor is used, <see cref="Initialize(KeyParams)"/> is called automatically.</para>
        /// </summary>
        /// 
        /// <param name="Key">HMAC Key; passed to HMAC Initialize() through constructor</param>
        /// <param name="DisposeEngine">Dispose of digest engine when <see cref="Dispose()"/> on this class is called</param>
        /// 
        /// <exception cref="CryptoMacException">Thrown if a null Key is used</exception>
        public SHA256HMAC(byte[] Key, bool DisposeEngine = true)
        {
            if (Key == null)
                throw new CryptoMacException("SHA256HMAC:Ctor", "Key can not be null!", new ArgumentNullException());

            _shaDigest = new SHA256();
            _shaHmac = new HMAC(_shaDigest, Key, DisposeEngine);
            _isInitialized = true;
        }
Esempio n. 2
0
 /// <summary>
 /// Initialize the class
 /// <para>When using this constructor, you must call <see cref="Initialize(KeyParams)"/> before processing.</para>
 /// </summary>
 /// 
 /// <param name="DisposeEngine">Dispose of digest engine when <see cref="Dispose()"/> on this class is called</param>
 public SHA256HMAC(bool DisposeEngine = true)
 {
     _shaDigest = new SHA256();
     _shaHmac = new HMAC(_shaDigest, DisposeEngine);
 }