Advertisement
informaticage

Cifrario di Cesare Python

Feb 9th, 2021
1,260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. # Loops
  2. # While, For
  3.  
  4. # Find divisors
  5. # Primality test
  6.  
  7. # n * ( n - 1 ) * ( n - 2 ) .... 1
  8.  
  9. # indovinda il numero
  10.  
  11. stringa = input('stringa: ')
  12. key = int(input("Chiave di Cesare: "))
  13.  
  14. for c in stringa:
  15.     posizione_alfabetica = ord(c) - ord('A')
  16.     # print(posizione_alfabetica)
  17.  
  18.     posizione_cifrata = key + posizione_alfabetica
  19.     posizione_cifrata = posizione_cifrata % 26
  20.  
  21.     # print(posizione_cifrata)
  22.     print(chr(posizione_cifrata + ord('A')), end="")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement