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(); |
Partager