Bonjour,
Pour encrypter et décrypter un fichier, j'ai décidé d'utiliser la méthode BlowFish.
Pour l'encryptage, j'ai utilisé la méthode suivante sans aucun problème.
Par contre pour le décryptage, je n'arrive pas à trouver la solution. Ci-dessous un des bouts de code que j'ai testés.
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 procedure TForm1.ButtonEncClick(Sender: TObject); var VInput, VOutput: TMemoryStream; VCypher: TBlowfishEncryptStream; begin VOutput := TMemoryStream.create; VCypher := TBlowfishEncryptStream.create('MotDePasse', VOutput); try VInput := TMemoryStream.create; VInput.LoadFromFile('FichierDepart.txt'); VCypher.writebuffer(VInput.memory, VInput.size); VOutput.SaveToFile('FichierEncrypter.enc'); finally VCypher.free; VInput.free; VOutput.free; end; end;
Si quelqu'un a une idée de solution
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 procedure TForm1.ButtonDecClick(Sender: TObject); var VInput, VOutput: TMemoryStream; VCypher: TBlowFishDecryptStream; begin VInput := TMemoryStream.create; VInput.LoadFromFile('FichierEncrypter.enc'); VOutput := TMemoryStream.create; VCypher := TBlowFishDecryptStream.create('MotDePasse', VInput); VCypher.Position:=0; Voutput.copyfrom( VCypher, VInput.Size); VOutput.SaveToFile('FichierDecrypter.dec'); VCypher.free; VInput.free; VOutput.free; end;
Merci
Partager