summaryrefslogtreecommitdiff
path: root/cesar.py
blob: ca6fb12b907c1c13d4a0c5d175476cb77d082b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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=""