Created
February 16, 2022 16:32
-
-
Save cazeip/a75ea8c8f0e3e199544b6a4e4cc703e7 to your computer and use it in GitHub Desktop.
Revisions
-
cazeip revised this gist
Feb 16, 2022 . 1 changed file with 69 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,70 @@ from math import * def encrypt(): key = input("Veuillez entrer votre cle\n(lettres, sans espace)\n$ ").lower() msg = input("Veuillez entrer le message\n$ ").lower() calculateEncryption(key, msg) def calculateEncryption(key, msg): str = "" count = 0 unsupported = -1 for i in range(len(msg)): if alphabet.find(msg[i]) == -1 and msg[i] != " ": unsupported = i break elif msg[i] != " ": str += alphabet[((alphabet.find(msg[i])) + (alphabet.find(key[count % len(key)]))) % 26] count += 1 else: str += " " if unsupported != -1: print("Charactere \""+msg[unsupported]+"\" n'est pas\nsupporte") else: print(str) input("\nAppuyez sur entree pour\ncontinuer...") menu() def decrypt(): key = input("Veuillez entrer votre cle\n(lettres, sans espace)\n$ ").lower() msg = input("Veuillez entrer le message\n$ ").lower() calculateDecryption(key, msg) def calculateDecryption(key, msg): str = "" count = 0 unsupported = -1 for i in range(len(msg)): if alphabet.find(msg[i]) == -1 and msg[i] != " ": unsupported = i break elif msg[i] != " ": str += alphabet[((alphabet.find(msg[i])) - (alphabet.find(key[count % len(key)])))] count += 1 else: str += " " if unsupported != -1: print("Charactere \""+msg[unsupported]+"\" n'est pas\nsupporte") else: print(str) input("\nAppuyez sur entree pour\ncontinuer...") menu() def menu(): ans = input("Souhaitez vous\n 1. Crypter\n 2. Decrypter\n 3. Sortir\n$ ") if ans == "1": encrypt() elif ans == "2": decrypt() elif ans == "3": print("A Bientot") else: print("Reponse invalide") input("\nAppuyez sur entree pour\ncontinuer...") menu() alphabet = "abcdefghijklmnopqrstuvwxyz" separator = "=================" print(separator+"\nCodeur et decodeur de\nchiffrement vigenere\n"+separator) menu() -
cazeip created this gist
Feb 16, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ from math import *