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

            while (_cipherPool.Count > 0)
            {
                while (!_cipherPool.TryPop(out aes))
                {
                }
                aes.Dispose();
            }
        }
예제 #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);
        }
예제 #5
0
 public void Dispose()
 {
     _internalCrypto.Dispose();
 }
예제 #6
0
 public void Dispose()
 {
     _gcm.Dispose();
 }
예제 #7
0
 public void Dispose()
 {
     _aes.Dispose();
 }
 public void Dispose()
 {
     _aesGcmCipher.Dispose();
 }
예제 #9
0
 public override void Dispose()
 {
     algorithm.Dispose();
 }