Advertisement
brilliant_moves

CaesarCipher.py

Jun 11th, 2015
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. #!/usr/bin/python
  2. #CaesarCipher.py
  3. #Python 2.7
  4. #By Chris Clarke
  5. #11.06.2015
  6.  
  7. def main():
  8.    message = raw_input ("Please enter message to encode: ").lower()
  9.    offset = int (input ("Enter offset: "))
  10.    result = ""
  11.    for ch in message:
  12.       x = ord(ch) + offset
  13.       if ch.isalpha() and x > ord('z'): # wrap around
  14.          x -= 26
  15.       result += chr(x)
  16.    print result
  17.  
  18. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement