weturtle

caesar_cipher

Feb 15th, 2019
6,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. plainText = input("Digita una parola in lettera minuscola: ")
  2. distance = int(input("Digita il valore della distanza (intero positivo < 26): "))
  3.  
  4. w = ""
  5. cipherValue = []
  6.  
  7. for ch in plainText:
  8.     n = 0
  9.     ordValue = ord(ch)
  10.  
  11.     if ordValue <= 120:
  12.         cipherValue.append(ordValue + distance)
  13.     else:
  14.         cipherValue.append(ordValue - (26 - distance))
  15.     n = n + 1
  16.  
  17. print("La parola criptata รจ: ", end='')
  18.  
  19. for n in cipherValue:
  20.     crypto = chr(n)
  21.     print(crypto, end='')
Advertisement
Add Comment
Please, Sign In to add comment