Skip to content

Instantly share code, notes, and snippets.

@packetchef
Created July 21, 2015 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packetchef/8c346fa2d85e34da15f6 to your computer and use it in GitHub Desktop.
Save packetchef/8c346fa2d85e34da15f6 to your computer and use it in GitHub Desktop.
Demonstrate rot13 encoding
import string
rot13 = string.maketrans(
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz",
"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm"
)
encodedString = string.translate('Hypatia', rot13)
decodedString = string.translate(encodedString, rot13)
print('Encoded string is {string}'.format(string=encodedString))
print('Decoded string is {string}'.format(string=decodedString))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment