Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- listeM = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- listeM += listeM
- listem = 'abcdefghijklmnopqrstuvwxyz'
- listem += listem
- listex = ',;:!?.@/§%¨^*£$¤}=+°)]^\'_`|-[({"~&0123456789çéèàùûêôîâ'
- listex += listex
- message = input('Entrez votre message : ')
- def dechiffrage_lettre(lettre,listeM,listem,listex,cle):
- for i in range(len(listeM)):
- if listeM[i]==lettre:
- return str(listeM[i-cle])
- elif lettre==' ': #au cas ou il y a un espace
- return ' '
- for m in range (len(listem)):
- if listem[m]==lettre:
- return str(listem[m-cle])
- elif lettre==' ': #au cas ou il y a un espace
- return ' '
- for x in range (len(listex)):
- if listex[x]==lettre:
- if lettre=='é':
- return str(listem[4-cle])
- else:
- if lettre=='è':
- return str(listem[4-cle])
- else:
- if lettre=='ê':
- return str(listem[4-cle])
- else:
- if lettre=='à':
- return str(listem[0-cle])
- else:
- if lettre=='â':
- return str(listem[0-cle])
- else:
- if lettre=='ù':
- return str(listem[20-cle])
- else:
- if lettre=='û':
- return str(listem[20-cle])
- else:
- if lettre=='ô':
- return str(listem[14-cle])
- else:
- if lettre=='î':
- return str(listem[8-cle])
- else:
- if lettre=='ç':
- return str(listem[2-cle])
- else:
- return str(listex[x])
- elif lettre==' ': #au cas ou il y a un espace
- return ' '
- #########################################
- #Pour un message dont on connait la clé de decryptage
- #########################################
- cle = int(input('Entrez votre clef : '))
- message_dechiffre = str()
- for lettre in message:
- message_dechiffre += dechiffrage_lettre(lettre,listeM,listem,listex,cle)
- print(message_dechiffre)
- ##########################################
- #Pour un message dont on ne connait pas la clé de décryptage (si vous décommentez cette partie, il faut commenter l'autre)
- ##########################################
- #for cle in range(26):
- # message_dechiffre = str()
- # for lettre in message:
- # message_dechiffre += dechiffrage_lettre(lettre,listeM,listem,listex,cle)
- # print(cle)
- # print(message_dechiffre)
Advertisement
Add Comment
Please, Sign In to add comment