frederick99

Cesaer cipher

Sep 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1.  
  2. from string import ascii_lowercase as lower, ascii_uppercase as upper
  3.  
  4. def rot(n: int) -> dict:
  5.     return dict(zip(lower[n:]+lower[:n]+upper[n:]+upper[:n], lower+upper))
  6.  
  7. def decode(s: str, n: int) -> str:
  8.     mapping = rot(n)
  9.     return ''.join(mapping.get(c,c) for c in s)
  10.  
  11. print(decode('Jgnnq, yqtnf!', 2))
Add Comment
Please, Sign In to add comment