Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #python3
- class CaeserCipher(object):
- """A pythonic implementation of CaserCipher"""
- def __init__(self, offset):
- self.offset = offset
- def encode(self, message):
- """/
- Take a message and encode it buy adding the offset value to each charecter.
- """
- return ''.join([chr(ord(i)+self.offset) for i in message])
- def decode(self, message):
- """/
- Take an encoded message and decode it by removing the offset
- """
- return ''.join([chr(ord(i)-self.offset) for i in message])
- if __name__ == '__main__':
- caeser = CaeserCipher(3)
- message = "Your momma's ass"
- encoded = caeser.encode(message)
- print("Message: " + message)
- print("Encoded: " + encoded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement