problem decrypting
i'm having trouble decrypting an encrypted text file and saving it into an output file. The error that i got was "PKCS7 padding is invalid and cannot be removed."
I'm wondering what's wrong with my code.
FileStream fsIn = File.Open(file,FileMode.Open,FileAccess.Read);
FileStream fsOut = File.Open(tempfile, FileMode.OpenOrCreate,FileAccess.Write);
ICryptoTransform transform = symm.CreateDecryptor();
CryptoStream cstream = new CryptoStream(fsOut,transform,CryptoStreamMode.Writ e);
BinaryReader br = new BinaryReader(fsIn);
cstream.Write(br.ReadBytes((int)fsIn.Length),0,(in t)fsIn.Length);
cstream.FlushFinalBlock();
cstream.Close();
fsIn.Close();
fsOut.Close();
|