Advertisement
Guest User

caesar cipher

a guest
Jan 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys,string
  4.  
  5. def caesar(plaintext, shift):
  6.     alphabet = string.ascii_lowercase
  7.     shifted_alphabet = alphabet[shift:] + alphabet[:shift]
  8.     table = str.maketrans(alphabet, shifted_alphabet)
  9.     return plaintext.translate(table)
  10.  
  11. source = input("Please input your text: ")
  12. shift = input("Please input shift: ")
  13. print(caesar(source, int(shift)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement