summaryrefslogtreecommitdiff
path: root/cesar.py
blob: 15d7ce2dfcca9228e548c6743da818d2040afacd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import string

def decalage(lettre,clef):
    liste=list(string.ascii_lowercase)*2 + list(string.ascii_uppercase)*2
    if lettre not in liste:
        return lettre
    else:
        return liste[liste.index(lettre)+clef]

msg_chiffre = str()
while True:
    msg = input('Entrez le texte à chiffrer (q pour quitter) : ')
    if msg.lower() == "q":
        print("bye")
        exit()
    clef = int(input('Entrez votre clef : '))
    for lettre in msg:
        msg_chiffre += decalage(lettre,clef)
    print(msg_chiffre)
    msg_chiffre = ""