i Team,C# exception de cryptage
J'ai le code de cryptage suivant en C#. Je reçois une exception comme Specified initialization vector (IV) does not match the block size for this algorithm.
Pourriez-vous s'il vous plaît me dire quel est le chaînon manquant ici?
//Key and IV for RSA Encryption
byte[] ketByte = Encoding.UTF8.GetBytes("C3CA193570B26E5C3CBB50FD805A01S2");
byte[] IVByte = Encoding.UTF8.GetBytes("C3FG563570FG565C3CBB50FD805A01S2");
//Read image
Image sourceImg = Image.FromFile(@"D:\ImageSource\Cha1.bmp");
//Convert to Byte[]
byte[] byteArray = ImageToByteArray(sourceImg);
//Encrypt
byte[] encryptedByteArray = EncryptByte(byteArray, ketByte, IVByte);
public static byte[] EncryptByte(byte[] palinData, byte[] Key, byte[] theInitializationVector)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Security.Cryptography.Rijndael algorithm = System.Security.Cryptography.Rijndael.Create();
algorithm.Key = Key;
algorithm.IV = theInitializationVector; //Exception
System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(ms,algorithm.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
cStream.Write(palinData, 0, palinData.Length);
cStream.Close();
byte[] encryptedData = ms.ToArray();
return encryptedData;
}
Merci
Lijo
duplication possible de [Le vecteur d'initialisation spécifié (IV) ne correspond pas à la taille de bloc pour cet algorithme.] (Http://stackoverflow.com/questions/944833/specified-initialization-vector-iv-does-not-match -le-block-size-for-this-algor) –