Last active
July 9, 2020 09:22
-
-
Save tfeldmann/cb511d9e1c8fcddd3288abfb25f1f366 to your computer and use it in GitHub Desktop.
ROT18 implementation in python and c
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
void rot18(char *c) | |
{ | |
while (*c) | |
{ | |
if (*c >= 'A' && *c <= 'Z') | |
*c = ('A' + (*c - 'A' + 13) % 26); | |
else if (*c >= 'a' && *c <= 'z') | |
*c = ('a' + (*c - 'a' + 13) % 26); | |
else if (*c >= '0' && *c <= '9') | |
*c = ('0' + (*c - '0' + 5) % 10); | |
c++; | |
} | |
} |
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
ROT18 = str.maketrans( | |
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz0123456789", | |
"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm5678901234", | |
) | |
def rot18(text): | |
return text.translate(ROT18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment