The rotor Module

(Optional) The rotor module implements a simple encryption algorithm, shown in Example 2-42, which is based on the WWII Enigma engine.

Example 2-42. Using the rotor Module

File: rotor-example-1.py

import rotor

SECRET_KEY = "spam"
MESSAGE = "the holy grail"

r = rotor.newrotor(SECRET_KEY)

encoded_message = r.encrypt(MESSAGE)
decoded_message = r.decrypt(encoded_message)

print "original:", repr(MESSAGE)
print "encoded message:", repr(encoded_message)
print "decoded message:", repr(decoded_message)

original: 'the holy grail'
encoded message: '22727124415305sw3340337252237340U'
decoded message: 'the holy grail'
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.188.121