System.Security.Cryptography.HMACSHA1.Dispose C# (CSharp) Method

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                HMACCommon hMacCommon = _hMacCommon;
                _hMacCommon = null;
                if (hMacCommon != null)
                    hMacCommon.Dispose(disposing);
            }
            base.Dispose(disposing);
        }

Usage Example

        public void TestHMACs2(int key, int value)
        {
            byte[] keyB = new byte[key];
            byte[] valueB = new byte[value];

            rng.GetBytes(keyB);
            rng.GetBytes(valueB);

            var code = HMAC<Sha1Digest>.Compute(keyB, valueB);

            HMACSHA1 hmac1 = new HMACSHA1(keyB);
            var code2 = hmac1.ComputeHash(valueB);
            if (!code.SequenceEqual(code2))
                throw new Exception();


            hmac1.Dispose();
        }