Created
August 11, 2017 14:18
-
-
Save ronaldstoner/24f234a9b2f896e645ae885dd818ee95 to your computer and use it in GitHub Desktop.
ciphertext.py
This file contains 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
# ARCYBER cipher text generator | |
# Modified from existing code on the internet | |
def subchar(a, b): | |
return (((ord(b)-97) - (ord(a)-97)) % 26) + 97 | |
def getkey(question, answer): | |
assert len(question) == len(answer), 'Length mismatch' | |
q = question.lower() | |
a = answer.lower() | |
result = [] | |
for i in range(len(question)): | |
if question[i] == ' ': | |
char = ' ' | |
else: | |
char = chr(subchar(q[i], a[i])) | |
# if uppercase | |
if ord(question[i]) < 97: | |
char = char.upper() | |
result.append(char) | |
return ''.join(result) | |
one = 'rstoner leet hax omg' | |
two = 'Ccoheal ieuw qwu tcb' | |
getkey(one, two) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment