Salut,
J'utilise la bibliothèque (Crypto) d' OpenSSL dans mon programme C# à fin de crypter/décrypter les fichiers. Voila mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
byte[] key = System.Text.Encoding.ASCII.GetBytes("password");
 
            byte[] iv = System.Text.Encoding.ASCII.GetBytes("1234");
 
 
            OpenSSL.Crypto.CipherContext cc = new OpenSSL.Crypto.CipherContext(OpenSSL.Crypto.Cipher.AES_256_ECB);
 
            FileStream fIn = new FileStream("C:\\users\\monFichier.txt", FileMode.Open, FileAccess.Read);
            FileStream fOut = new FileStream("C:\\users\\resultat.txt", FileMode.OpenOrCreate, FileAccess.Write);
            fOut.SetLength(0);
 
 
            byte[] bin = new byte[100];
            long rdlen = 0;
            long totlen = fIn.Length;
            int len;
 
            DateTime start = DateTime.Now;
            while (rdlen < totlen)
            {
                len = fIn.Read(bin, 0, 100);
                fOut.Write(cc.Crypt(bin,key,iv,false),0,100);//Ecriture du bloc 
                rdlen = rdlen + len;
            }
 
            fOut.Flush();
 
            fOut.Close();
            fIn.Close();
Lors de l'execution j'obtiens l'exeption suivante
Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
j'ai changé les deux valeurs de fOut et len de 100 à 64 alors que bin est resté à 100 alors j'ai pu crypter/décrypter sauf que le fichier résultant du décryptage contient quelques octets de plus que le fichier original et du coup j'ai quelques ligne a la fin du fichier qui se répètent.

Merci pour votre aide, cordialement.