Advertisement
Rythorian

Untitled

Feb 17th, 2025
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public static void DecryptFile(string encryptedFilePath, byte[] key, byte[] iv)
  2. {
  3. using (var aes = Aes.Create())
  4. {
  5. aes.KeySize = KeySize;
  6. aes.BlockSize = BlockSize;
  7. aes.Key = key;
  8. aes.IV = iv;
  9.  
  10. using (var encryptedFileStream = new FileStream(encryptedFilePath, FileMode.Open, FileAccess.Read))
  11. using (var decryptedFileStream = new FileStream(encryptedFilePath.Replace(".enc", ""), FileMode.Create, FileAccess.Write))
  12. using (var cryptoStream = new CryptoStream(encryptedFileStream, aes.CreateDecryptor(), CryptoStreamMode.Read))
  13. {
  14. cryptoStream.CopyTo(decryptedFileStream);
  15. }
  16. }
  17. File.Delete(encryptedFilePath);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement