diff options
| author | jerome <jerome@xlinfo.fr> | 2023-12-27 17:47:12 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2023-12-27 17:47:12 +0100 |
| commit | 67c94bcdabad901f1e690d373d30417847f8009c (patch) | |
| tree | 9944b962a5077ca917f85ae47651134d29681754 /cesar.py | |
| parent | 13f1f7fa8036c9030ad48c10bfe58a2099ce82af (diff) | |
| download | python-67c94bcdabad901f1e690d373d30417847f8009c.tar.gz python-67c94bcdabad901f1e690d373d30417847f8009c.zip | |
ajouts
Diffstat (limited to 'cesar.py')
| -rw-r--r-- | cesar.py | 20 |
1 files changed, 20 insertions, 0 deletions
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="" |
