Cryptage problème dans mon programme
Noralltach
Messages postés
5
Date d'inscription
Statut
Membre
Dernière intervention
-
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
jordane45 Messages postés 38486 Date d'inscription Statut Modérateur Dernière intervention -
Rebonjour,
me voilà avec une nouvelle question j'ai essayer de résoudre mon problème d'algorithme de cryptage mais je bute sur autre chose, j'ai fais un gros programme bête et méchant, mais il ne fonctionne pas je suis sur que c'est juste une toute petite ligne qui manque!
mon programme:
Je suis sur que c'est une commande print qui manque (je sais le code est moche bête, beaucoup trop long mais étant débutant j'ai rien trouvé de plus intelligent)
Merci!
me voilà avec une nouvelle question j'ai essayer de résoudre mon problème d'algorithme de cryptage mais je bute sur autre chose, j'ai fais un gros programme bête et méchant, mais il ne fonctionne pas je suis sur que c'est juste une toute petite ligne qui manque!
mon programme:
print(" ") print(" ") print(" ") print("Welcome to Lych-Krypt, our duty: your privacy") print(" ") input_text = input("Enter text you want to encrypt: ") print(input_text.upper()) dict_encrypt={"A":548, "B":43, "C":67, "D":27, "E":386, "F":984, "G":265, "H":24, "I":242, "J":148, "K":253, "L":233, "M":478, "N":1032, "O":85, "P":234, "Q":170, "R":394, "S":613, "T":43, "U":572, "V":841, "W":99, "X":314, "Y":38, "Z":56} def encrypt(input_text): for x in range(len(input_text)): if x%2==0: if input_text[x] == "A": num_encrypt1 = dict_encrypt("A")+63 elif input_text[x] == "B": num_encrypt2 = dict_encrypt("B")+63 elif input_text[x] == "C": num_encrypt3 = dict_encrypt("C")+63 elif input_text[x] == "D": num_encrypt4 = dict_encrypt("D")+63 elif input_text[x] == "E": num_encrypt5 = dict_encrypt("E")+63 elif input_text[x] == "F": num_encrypt6 = dict_encrypt("F")+63 elif input_text[x] == "G": num_encrypt7 = dict_encrypt("G")+63 elif input_text[x] == "H": num_encrypt8 = dict_encrypt("H")+63 elif input_text[x] == "I": num_encrypt9 = dict_encrypt("I")+63 elif input_text[x] == "J": num_encrypt10 = dict_encrypt("J")+63 elif input_text[x] == "K": num_encrypt11 = dict_encrypt("K")+63 elif input_text[x] == "L": num_encrypt12 = dict_encrypt("L")+63 elif input_text[x] == "M": num_encrypt13 = dict_encrypt("M")+63 elif input_text[x] == "N": num_encrypt14 = dict_encrypt("N")+63 elif input_text[x] == "O": num_encrypt15 = dict_encrypt("O")+63 elif input_text[x] == "P": num_encrypt16 = dict_encrypt("P")+63 elif input_text[x] == "Q": num_encrypt17 = dict_encrypt("Q")+63 elif input_text[x] == "R": num_encrypt17 = dict_encrypt("R")+63 elif input_text[x] == "S": num_encrypt19 = dict_encrypt("S")+63 elif input_text[x] == "T": num_encrypt20 = dict_encrypt("T")+63 elif input_text[x] == "U": num_encrypt21 = dict_encrypt("U")+63 elif input_text[x] == "V": num_encrypt22 = dict_encrypt("V")+63 elif input_text[x] == "W": num_encrypt23 = dict_encrypt("W")+63 elif input_text[x] == "X": num_encrypt24 = dict_encrypt("X")+63 elif input_text[x] == "Y": num_encrypt25 = dict_encrypt("Y")+63 elif input_text[x] == "Z": num_encrypt26 = dict_encrypt("Z")+63 elif x%3==0: if input_text[x] == "A": num_encrypt = dict_encrypt("A")-23 elif input_text[x] == "B": num_encrypt = dict_encrypt("B")-23 elif input_text[x] == "C": num_encrypt = dict_encrypt("C")-23 elif input_text[x] == "D": num_encrypt = dict_encrypt("D")-23 elif input_text[x] == "E": num_encrypt = dict_encrypt("E")-23 elif input_text[x] == "F": num_encrypt = dict_encrypt("F")-23 elif input_text[x] == "G": num_encrypt = dict_encrypt("G")-23 elif input_text[x] == "H": num_encrypt = dict_encrypt("H")-23 elif input_text[x] == "I": num_encrypt = dict_encrypt("I")-23 elif input_text[x] == "J": num_encrypt = dict_encrypt("J")-23 elif input_text[x] == "K": num_encrypt = dict_encrypt("K")-23 elif input_text[x] == "L": num_encrypt = dict_encrypt("L")-23 elif input_text[x] == "M": num_encrypt = dict_encrypt("M")-23 elif input_text[x] == "N": num_encrypt = dict_encrypt("N")-23 elif input_text[x] == "O": num_encrypt = dict_encrypt("O")-23 elif input_text[x] == "P": num_encrypt = dict_encrypt("P")-23 elif input_text[x] == "Q": num_encrypt = dict_encrypt("Q")-23 elif input_text[x] == "R": num_encrypt = dict_encrypt("R")-23 elif input_text[x] == "S": num_encrypt = dict_encrypt("S")-23 elif input_text[x] == "T": num_encrypt = dict_encrypt("T")-23 elif input_text[x] == "U": num_encrypt = dict_encrypt("U")-23 elif input_text[x] == "V": num_encrypt = dict_encrypt("V")-23 elif input_text[x] == "W": num_encrypt = dict_encrypt("W")-23 elif input_text[x] == "X": num_encrypt = dict_encrypt("X")-23 elif input_text[x] == "Y": num_encrypt = dict_encrypt("Y")-23 elif input_text[x] == "Z": num_encrypt = dict_encrypt("Z")-23 else: if input_text[x] == "A": num_encrypt = dict_encrypt("A")*7 elif input_text[x] == "B": num_encrypt = dict_encrypt("B")*7 elif input_text[x] == "C": num_encrypt = dict_encrypt("C")*7 elif input_text[x] == "D": num_encrypt = dict_encrypt("D")*7 elif input_text[x] == "E": num_encrypt = dict_encrypt("E")*7 elif input_text[x] == "F": num_encrypt = dict_encrypt("F")*7 elif input_text[x] == "G": num_encrypt = dict_encrypt("G")*7 elif input_text[x] == "H": num_encrypt = dict_encrypt("H")*7 elif input_text[x] == "I": num_encrypt = dict_encrypt("I")*7 elif input_text[x] == "J": num_encrypt = dict_encrypt("J")*7 elif input_text[x] == "K": num_encrypt = dict_encrypt("K")*7 elif input_text[x] == "L": num_encrypt = dict_encrypt("L")*7 elif input_text[x] == "M": num_encrypt = dict_encrypt("M")*7 elif input_text[x] == "N": num_encrypt = dict_encrypt("N")*7 elif input_text[x] == "O": num_encrypt = dict_encrypt("O")*7 elif input_text[x] == "P": num_encrypt = dict_encrypt("P")*7 elif input_text[x] == "Q": num_encrypt = dict_encrypt("Q")*7 elif input_text[x] == "R": num_encrypt = dict_encrypt("R")*7 elif input_text[x] == "S": num_encrypt = dict_encrypt("S")*7 elif input_text[x] == "T": num_encrypt = dict_encrypt("T")*7 elif input_text[x] == "U": num_encrypt = dict_encrypt("U")*7 elif input_text[x] == "V": num_encrypt = dict_encrypt("V")*7 elif input_text[x] == "W": num_encrypt = dict_encrypt("W")*7 elif input_text[x] == "X": num_encrypt = dict_encrypt("X")*7 elif input_text[x] == "Y": num_encrypt = dict_encrypt("Y")*7 elif input_text[x] == "Z": num_encrypt = dict_encrypt("Z")*7 print("Encryption complete")
Je suis sur que c'est une commande print qui manque (je sais le code est moche bête, beaucoup trop long mais étant débutant j'ai rien trouvé de plus intelligent)
Merci!
EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI Merci d'y penser dans tes prochains messages. |
A voir également:
- Cryptage problème dans mon programme
- Programme demarrage windows - Guide
- Cette action ne peut pas être réalisée car le fichier est ouvert dans un autre programme - Guide
- Mettre en veille un programme - Guide
- Message programmé iphone - Guide
- Programme word gratuit - Guide
1 réponse
Bonjour,
Je ne fais pas de python...
mais pourquoi faire if ELIF ... du genre
alors qu'il suffirait d'une seule ligne de code
Et pourquoi dans un cas tu nommes toutes tes variables num_encrypt .. et que dans l'autre tu y ajoute un numéro num_encrypt1 num_encrypt2 ... ?
Je ne fais pas de python...
mais pourquoi faire if ELIF ... du genre
if input_text[x] == "A": num_encrypt = dict_encrypt("A")-23 elif input_text[x] == "B": num_encrypt = dict_encrypt("B")-23 etc...
alors qu'il suffirait d'une seule ligne de code
num_encrypt = dict_encrypt(input_text[x])-23
Et pourquoi dans un cas tu nommes toutes tes variables num_encrypt .. et que dans l'autre tu y ajoute un numéro num_encrypt1 num_encrypt2 ... ?
je concède que les variable num_encrypt est mal faite, ce que j'aurais du écrire c'est:
num_encrypt=""
num_encrypt=dict_encrypt("lettre")+63
print(num_encrypt)
num_encrypt=""
Quoi qu'il en soit, en regardant ton code, je ne vois que 3 conditions
Ensuite, soit tu génères l'affichage à chaque tout de ta boucle
Soit tu trouves comment on concatène une chaine de caractères et tu fais ton print APRES ta boucle
NB: Et par contre, comment feras tu pour décrypter ? Je pense qu'il faut que tu mettes un caractère séparateur entre chaque "lettre" ou que tu mettes le même nombre de "chiffre" pour chaque encodage...