public void Aes256_GCM_Stream() { var hashKey = _hashingProvider.GetHashKey(Passphrase, Salt, 32); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new BouncyAesGcmEncryptionProvider(hashKey); var encryptedStream = encryptionProvider.Encrypt(new MemoryStream(_data)); var decryptedStream = encryptionProvider.Decrypt(encryptedStream); Assert.Equal(_data, decryptedStream.ToArray()); }
public async Task Aes256_GCM_StreamAsync() { var hashKey = await _hashingProvider .GetHashKeyAsync(Passphrase, Salt, 32) .ConfigureAwait(false); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new BouncyAesGcmEncryptionProvider(hashKey); var encryptedStream = await encryptionProvider.EncryptAsync(new MemoryStream(_data)); var decryptedStream = encryptionProvider.Decrypt(encryptedStream); Assert.Equal(_data, decryptedStream.ToArray()); }
public async Task Aes192_GCM() { var hashKey = await _hashingProvider .GetHashKeyAsync(Passphrase, Salt, 24) .ConfigureAwait(false); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new BouncyAesGcmEncryptionProvider(hashKey); var encryptedData = encryptionProvider.Encrypt(_data); _output.WriteLine($"Encrypted: {Encoding.UTF8.GetString(encryptedData)}"); var decryptedData = encryptionProvider.Decrypt(encryptedData); _output.WriteLine($"Data: {Encoding.UTF8.GetString(_data)}"); _output.WriteLine($"Decrypted: {Encoding.UTF8.GetString(decryptedData)}"); Assert.Equal(_data, decryptedData); }