daily pastebin goal
19%
SHARE
TWEET

caesar cipher

a guest Jan 24th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top