Created
June 20, 2011 02:35
-
-
Save exallium/1035036 to your computer and use it in GitHub Desktop.
XOR Cipher in Python
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
INFILE="input.txt" | |
OUTFILE="output.txt" | |
key = "asdf" | |
fin = open(INFILE, "rb") | |
x = fin.read() | |
l = len(x) | |
key = key * (l/len(key)) | |
o = "" | |
index = 0 | |
for item in x: | |
o += chr(ord(item) ^ ord(key[index])) | |
index = (index + 1)%len(key) | |
fin.close() | |
fout = open(OUTFILE, "w") | |
fout.write(o) | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment