Fix chiffrement_affine
This commit is contained in:
parent
5b1dd1834c
commit
77812cc19e
1 changed files with 3 additions and 3 deletions
|
@ -18,15 +18,16 @@ def main():
|
|||
action = input("Chiffrer ou déchiffrer ? ")
|
||||
|
||||
alphabet = input("Alphabet pour le chiffrement affine, terminez par Entrée : ")
|
||||
n = len(alphabet)
|
||||
a, b = input(
|
||||
"Clé de chiffrement (deux nombres séparés par un espace, exemple: 2 4) "
|
||||
).split(" ")[:2]
|
||||
kc = (int(a), int(b))
|
||||
inv_a = inverser(a)
|
||||
inv_a = inverser(int(a), n)
|
||||
if not inv_a:
|
||||
print(f"{a} doit être inversible")
|
||||
return
|
||||
op_b = opposer(b)
|
||||
op_b = opposer(int(b), n)
|
||||
kd = (inv_a, (inv_a * op_b) % n)
|
||||
|
||||
if action == "chiffrer":
|
||||
|
@ -63,6 +64,5 @@ def dechiffrer(message: str, alphabet: str, cle: tuple[int, int]):
|
|||
return output
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue