Created
February 10, 2020 05:24
-
-
Save ahmed4end/22b0d839fce6dc777f950f3f6ea58a23 to your computer and use it in GitHub Desktop.
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
text = "hello" | |
key = "key" | |
if len(key)<len(text):key=key*(len(text)//len(key)+1) #fix key length if shorter than text. | |
res = [] | |
for i,j in enumerate(text): | |
res.append(chr(ord(j)^ord(key[i]))) | |
text = "".join(res) | |
print("encode: ", text) | |
res = [] | |
for i,j in enumerate(text): | |
res.append(chr(ord(j)^ord(key[i]))) | |
print("decode: ", "".join(res)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment