Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #CaesarCipher2.py
- #Python 2.7
- cipher = ''
- alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
- message = raw_input ("What message would you like to encrypt? ... ").lower()
- shift = int (input ("What is the shift key? ... "))
- for c in message:
- if c.isalpha():
- cipher += alphabet [(alphabet.index (c) + shift) % (len (alphabet))]
- else:
- cipher += c
- print cipher
Advertisement
Add Comment
Please, Sign In to add comment