Не удалось расшифровать файл с помощью алгоритма AES, iv dosenot соответствует размеру блока C#
Привет,
В приведенном ниже коде я не могу расшифровать этот файл
я получаю ошибку в качестве пути, используемого другой программой.Iv доза не соответствует размеру блока
Что я уже пробовал:
namespace File_Encryption { class AES { public void EncryptFile(string inputFile, string outputFile) { try { string password = @"pwd123$"; // Your Key Here UnicodeEncoding UE = new UnicodeEncoding(); byte[] key = UE.GetBytes(password); string cryptFile = outputFile; FileStream fsCrypt = new FileStream(cryptFile, FileMode.Create); RijndaelManaged RMCrypto = new RijndaelManaged(); CryptoStream cs = new CryptoStream(fsCrypt,RMCrypto.CreateEncryptor(key,key),CryptoStreamMode.Write); FileStream fsIn = new FileStream(inputFile, FileMode.Open); int data; while ((data = fsIn.ReadByte()) != -1) cs.WriteByte((byte)data); fsIn.Close(); cs.Close(); fsCrypt.Close(); } catch(Exception e) { } } ///<summary> /// Steve Lydford - 12/05/2008. /// /// Decrypts a file using Rijndael algorithm. ///</summary> ///<param name="inputFile"></param> ///<param name="outputFile"></param> public void DecryptFile(string inputFile, string outputFile) { { string password = @"pwd123$"; // Your Key Here UnicodeEncoding UE = new UnicodeEncoding(); byte[] key = UE.GetBytes(password); FileStream fsCrypt = new FileStream(inputFile, FileMode.Open); RijndaelManaged RMCrypto = new RijndaelManaged(); CryptoStream cs = new CryptoStream(fsCrypt,RMCrypto.CreateDecryptor(key, key),CryptoStreamMode.Read); FileStream fsOut = new FileStream(outputFile, FileMode.Create); int data; while ((data = cs.ReadByte()) != -1) fsOut.WriteByte((byte)data); fsOut.Close(); cs.Close(); fsCrypt.Close(); } } } }
using System; using System.IO; using System.Text; using System.Data; using File_Encryption; namespace dsfsd { class Program { public static void Main() { File_Encryption.AES a=new AES(); a.EncryptFile("E:\\Anusha\\Path.txt","E:\\Anusha\\path.enc","123456"); a.DecryptFile("E:\\Anusha\\Path.enc","E:\\Anusha\\path.dec","123456"); } } }