Created
June 10, 2018 16:00
-
-
Save akkefa/e87b6d8d94ba20c63007123c8e801c74 to your computer and use it in GitHub Desktop.
Rot13 is a cipher: it rotates characters forward 13 places. This makes text unreadable. But as a cipher, it is reversible by applying the translation a second time. We write rot13 with maketrans and translate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create translation table. | |
trans = str.maketrans("abcdefghijklmnopqrstuvwxyz", | |
"nopqrstuvwxyzabcdefghijklm") | |
# Apply rot13 translation. | |
print("gandalf".translate(trans)) | |
print("gandalf".translate(trans).translate(trans)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment