mirror of
https://github.com/BreizhHardware/chiff-affine.git
synced 2026-01-18 16:37:39 +01:00
End of the project
This commit is contained in:
Binary file not shown.
BIN
__pycache__/crypt_and_decrypt.cpython-39.pyc
Normal file
BIN
__pycache__/crypt_and_decrypt.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
__pycache__/find_key.cpython-39.pyc
Normal file
BIN
__pycache__/find_key.cpython-39.pyc
Normal file
Binary file not shown.
@@ -32,6 +32,7 @@ def chiffrementAffineByte(data: bytes, keya: int, keyb: int) -> bytes:
|
||||
y = (keya*x+keyb)%256
|
||||
return bytes([alphabet[y]])
|
||||
|
||||
|
||||
def inverse(a):
|
||||
""" Renvoie l'inverse du module de a et x par 256
|
||||
"""
|
||||
@@ -40,6 +41,7 @@ def inverse(a):
|
||||
x += 1
|
||||
return x
|
||||
|
||||
|
||||
def dechiffrementAffineByte(data: bytes, keya: int, keyb: int) -> bytes:
|
||||
""" Renvoie le byte data décrypté avec le chiffrement affine
|
||||
"""
|
||||
|
||||
@@ -55,6 +55,7 @@ def findKeywrite(data: bytes, dataout: bytes, filenameOut = 'result'):
|
||||
fdout.write(str(keyb))
|
||||
fdout.write("\n")
|
||||
|
||||
|
||||
def findKeyList(data: bytes, dataout: bytes):
|
||||
"""Renvoie la liste des couples de clé possible pour que data soit égale à dataout.
|
||||
"""
|
||||
@@ -68,6 +69,7 @@ def findKeyList(data: bytes, dataout: bytes):
|
||||
L.append(t)
|
||||
return L
|
||||
|
||||
|
||||
def comparKey(L: list, M: list) -> tuple:
|
||||
"""Compare les couples de clé valeur et renvoie le couple commun aux 2 listes M et L.
|
||||
"""
|
||||
@@ -75,3 +77,4 @@ def comparKey(L: list, M: list) -> tuple:
|
||||
for y in range(len(M)):
|
||||
if L[i] == M[y]:
|
||||
return L[i]
|
||||
|
||||
18
jeudetest.py
18
jeudetest.py
@@ -3,19 +3,21 @@ from find_key import *
|
||||
|
||||
|
||||
|
||||
#print(sortbyteFreq(byteFreq("data")))
|
||||
#findKeywrite(b'\xaa', b'\x20', "keyoutspace")
|
||||
#findKeywrite(b'\x31', b'\x65', "keyoute")
|
||||
print(sortbyteFreq(byteFreq("data")))
|
||||
findKeywrite(b'\xaa', b'\x20', "keyoutspace")
|
||||
findKeywrite(b'\x31', b'\x65', "keyoute")
|
||||
#print(findKeyList(b'\xaa', b'\x20'))
|
||||
#print(comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65')))
|
||||
print(comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65')))
|
||||
#cryptByteFile('tescrypt.txt', 1, 3, "resulttest2")
|
||||
#cryptByteFile('data', 1, 3, 'resultcryptdata')
|
||||
#cryptByteFile('monkey.jpg', 1, 3)
|
||||
#decryptByteFile('resulttest2', 1, 3, "decryptresult2")
|
||||
#decryptByteFile('resultcryptdata', 1, 3, 'resultdecryptdata')
|
||||
decryptByteFile('data',
|
||||
comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65'))[0],
|
||||
comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65'))[1],
|
||||
"dataDecrypted")
|
||||
#decryptByteFile('data',
|
||||
# comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65'))[0],
|
||||
# comparKey(findKeyList(b'\xaa', b'\x20'), findKeyList(b'\x31', b'\x65'))[1],
|
||||
# "dataDecrypted")
|
||||
#cryptByteFile('enemy-from-the-series-arcane-league-of-legends.mp3', 45, 76, 'enemyCrypted')
|
||||
#decryptByteFile('enemyCrypted', 45, 76, 'enemyDeCyted.mp3')
|
||||
cryptByteFile('../enemy-from-the-series-arcane-league-of-legends.mp3', 45, 85, '../enemyCrypted')
|
||||
decryptByteFile('../enemyCrypted', 45, 85, '../enemyDeCrypted')
|
||||
7
jeudetestdemo.py
Normal file
7
jeudetestdemo.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from crypt_and_decrypt import *
|
||||
from find_key import *
|
||||
|
||||
cryptByteFile('../demo.mp3', 45, 85, '../demoCrypted.mp3')
|
||||
print('Crypted')
|
||||
decryptByteFile('../demoCrypted.mp3', 45, 85, '../demoDeCrypted.mp3')
|
||||
print('Decrypted')
|
||||
Reference in New Issue
Block a user