Example #1
0
 protected override void OnDispose(bool disposing)
 {
     if (disposing)
     {
         _aes.Dispose();
     }
 }
Example #2
0
        protected void Cleanup()
        {
            AesGcm aes = null;

            while (_cipherPool.Count > 0)
            {
                while (!_cipherPool.TryPop(out aes))
                {
                }
                aes.Dispose();
            }
        }
Example #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    aes.Dispose();
                    aes = null;
                    iv  = null;
                }

                disposedValue = true;
            }
        }
        public static byte[] Encrypt(byte[] plainData, byte[] key)
        {
            var aes   = new AesGcm(key);
            var nonce = Encoding.UTF8.GetBytes(BitConverter.ToString(key).GetHashCode().ToString());

            byte[] cipherData = new byte[16 * (plainData.Length / 16 + 1)];
            byte[] tag        = new byte[AesGcm.TagByteSizes.MaxSize];
            aes.Encrypt(nonce, plainData, cipherData, tag);
            aes.Dispose();
            using var stream = new MemoryStream();
            stream.Write(cipherData, 0, cipherData.Length);
            stream.Write(DataTagSeperator, 0, DataTagSeperator.Length);
            stream.Write(tag, 0, tag.Length);
            stream.Write(TagNonceSeperator, 0, TagNonceSeperator.Length);
            stream.Write(nonce, 0, nonce.Length);
            byte[] r = stream.ToArray();
            stream.Close();
            return(r);
        }
 public void Dispose()
 {
     _internalCrypto.Dispose();
 }
Example #6
0
 public void Dispose()
 {
     _gcm.Dispose();
 }
Example #7
0
 public void Dispose()
 {
     _aes.Dispose();
 }
 public void Dispose()
 {
     _aesGcmCipher.Dispose();
 }
Example #9
0
 public override void Dispose()
 {
     algorithm.Dispose();
 }