fx16

Cryptage RSA

May 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. texte=input('Quel est le texte à coder ?')
  2. print('Quelle est la clef publique ? Format n,e :')
  3. n=int(input('n='))
  4. e=int(input('e='))
  5.  
  6.  
  7. caractères_accent=['é','è','ê','ë','à','â','ù','û','ô','ç','œ','æ']
  8. caractères_sans_accent=['e','e','e','e','a','a','u','u','o','c','oe','ae']
  9.  
  10. ponctuation=[',',';',':','!','?','.','\'','-']
  11. sans_ponctuation=['','','','','','',' ',' ']
  12.  
  13. for i in range(12):
  14.     texte=texte.replace(caractères_accent[i],caractères_sans_accent[i])
  15.  
  16. for j in range(8):
  17.     texte=texte.replace(ponctuation[j],sans_ponctuation[j])
  18.  
  19. texte=texte.upper()
  20.  
  21. texte=texte.replace(' ','') # pour suppripmer les espaces
  22.  
  23. print(texte)
  24.  
  25. def RSA(texte,n,e):
  26.     texte_crypté=[]
  27.     for lettre in texte:
  28.         rang=ord(lettre)-65
  29.         texte_crypté.append((rang**e)%n)
  30.     return texte_crypté
  31.  
  32. print(RSA(texte,n,e))
Add Comment
Please, Sign In to add comment