public byte[] Decrypt(SymmetricEncryptionParameters parameters, byte[] inData) { using (MemoryStream inDataStream = new MemoryStream(inData), outDataStream = new MemoryStream()) { this.Decrypt(parameters, inDataStream, outDataStream); return(outDataStream.ToArray()); } }
public void Decrypt(SymmetricEncryptionParameters parameters, Stream inStream, Stream outStream) { using (var algorithm = AlgorithmMap[parameters.Algorithm]()) { var iv = ExtractIv(inStream, algorithm.IV.Length); using (var cryptor = algorithm.CreateDecryptor(parameters.Key, iv)) using (var cryptoStream = new CryptoStream(outStream, cryptor, CryptoStreamMode.Write)) inStream.CopyTo(cryptoStream); } }
internal FileEncryptor( ISymmetricEncryptor symmetricEncryptor, IEncryptionKeyGenerator encryptionKeyGenerator, IConfigurationProvider configurationProvider, IFileNameManager fileNameManager, EncryptionKeyInput encryptionKeyInput, string vaultName) { var key = encryptionKeyGenerator.Generate(encryptionKeyInput); this.parameters = new SymmetricEncryptionParameters { Algorithm = AlgorithmType.Aes, Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7, Key = key }; this.symmetricEncryptor = symmetricEncryptor; this.configurationProvider = configurationProvider; this.fileNameManager = fileNameManager; this.vaultName = vaultName; }