Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void DecryptFile(string encryptedFilePath, byte[] key, byte[] iv)
- {
- using (var aes = Aes.Create())
- {
- aes.KeySize = KeySize;
- aes.BlockSize = BlockSize;
- aes.Key = key;
- aes.IV = iv;
- using (var encryptedFileStream = new FileStream(encryptedFilePath, FileMode.Open, FileAccess.Read))
- using (var decryptedFileStream = new FileStream(encryptedFilePath.Replace(".enc", ""), FileMode.Create, FileAccess.Write))
- using (var cryptoStream = new CryptoStream(encryptedFileStream, aes.CreateDecryptor(), CryptoStreamMode.Read))
- {
- cryptoStream.CopyTo(decryptedFileStream);
- }
- }
- File.Delete(encryptedFilePath);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement