protected override void OnDispose(bool disposing) { if (disposing) { _aes.Dispose(); } }
protected void Cleanup() { AesGcm aes = null; while (_cipherPool.Count > 0) { while (!_cipherPool.TryPop(out aes)) { } aes.Dispose(); } }
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(); }
public void Dispose() { _gcm.Dispose(); }
public void Dispose() { _aes.Dispose(); }
public void Dispose() { _aesGcmCipher.Dispose(); }
public override void Dispose() { algorithm.Dispose(); }