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 AesGcmEncryptionProvider(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 AesGcmEncryptionProvider(hashKey); var encryptedStream = await encryptionProvider.EncryptAsync(new MemoryStream(_data)); var decryptedStream = encryptionProvider.Decrypt(encryptedStream); Assert.Equal(_data, decryptedStream.ToArray()); }
public void Aes192_GCM() { var hashKey = _hashingProvider.GetHashKey(Passphrase, Salt, 24); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new AesGcmEncryptionProvider(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); }
public async Task Aes128_GCM_BouncyCastle() { var hashKey = await _hashingProvider .GetHashKeyAsync(Passphrase, Salt, 16) .ConfigureAwait(false); _output.WriteLine(Encoding.UTF8.GetString(hashKey)); _output.WriteLine($"HashKey: {Encoding.UTF8.GetString(hashKey)}"); var encryptionProvider = new AesGcmEncryptionProvider(hashKey, _hashingProvider.Type); 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); }