From 67c94bcdabad901f1e690d373d30417847f8009c Mon Sep 17 00:00:00 2001 From: jerome Date: Wed, 27 Dec 2023 17:47:12 +0100 Subject: ajouts --- cesar.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cesar.py (limited to 'cesar.py') diff --git a/cesar.py b/cesar.py new file mode 100644 index 0000000..ca6fb12 --- /dev/null +++ b/cesar.py @@ -0,0 +1,20 @@ +liste=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] + +def decalage(lettre,liste,clef): + for i in range(len(liste)): + if lettre not in liste: + return lettre + elif lettre==liste[i]: + return str(liste[i+clef]) + +message_chiffre = str() +while True: + message = input('Entrez le texte à chiffrer (q pour quitter) : ') + if message == "q" or message =="Q": + print("bye") + exit() + clef = int(input('Entrez votre clef : ')) + for lettre in message: + message_chiffre += decalage(lettre,liste,clef) + print(message_chiffre) + message_chiffre="" -- cgit v1.2.3