Skip to content

Commit 8e3e468

Browse files
committed
logique ddecryptage
1 parent 3ac1830 commit 8e3e468

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

src/analyzers/chacha20_analyzer.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import hashlib
22
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
33
from rich import print
4-
import os
4+
import os, struct
55

66
class ChaCha20_Analyzer:
77

@@ -37,9 +37,10 @@ def dechiffrer(self,chemin_fichier_chiffer : str ,clef :bytes)->str:
3737
else:
3838
try:
3939
with open(f"data/{chemin_fichier_chiffer}",'rb') as f:
40-
nonce = f.read(12)
40+
nonce = f.read(16)
4141
texte_chiffrer = f.read()
4242

43+
counter=0
4344
algorithm_chacha20 = algorithms.ChaCha20(clef,nonce)
4445
cipher = Cipher(algorithm_chacha20,mode=None)
4546
decrypteur = cipher.decryptor()
@@ -51,20 +52,4 @@ def dechiffrer(self,chemin_fichier_chiffer : str ,clef :bytes)->str:
5152
print(f"Une erreur est survenu : {e}")
5253

5354

54-
key=os.urandom(32)
55-
nonce =os.urandom(16)
56-
message = b"Ceci est un test"
57-
algo = algorithms.ChaCha20(key,nonce)
58-
cipher = Cipher(algo,mode=None)
59-
encryptor = cipher.encryptor()
60-
ct = encryptor.update(message)
61-
62-
print(ct)
63-
64-
decryptor = cipher.decryptor()
65-
dt = encryptor.update(ct)
66-
67-
print(dt)
68-
69-
# ChaCha20_Analyzer().dechiffrer("mission2.enc",)
70-
55+
# print(ChaCha20_Analyzer().dechiffrer("mission2.enc",os.urandom(32)))

0 commit comments

Comments
 (0)