Hari B

Hari B

  • NA
  • 139
  • 68k

encryption Issue

Oct 7 2016 6:09 AM
I got Error message like below   
 
"Specified initialization vector (IV) does not match the block size for this algorithm." 
 
code
            
string password = "hfrHSGHSBS";
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();
 

Answers (3)