diff --git a/crypto/tmp b/crypto/tmp new file mode 100644 index 0000000..5274a9d Binary files /dev/null and b/crypto/tmp differ diff --git a/crypto/xor_dec.py b/crypto/xor_dec.py new file mode 100644 index 0000000..d80c501 --- /dev/null +++ b/crypto/xor_dec.py @@ -0,0 +1,21 @@ +import sys + +key_len = int(sys.argv[2]) +def xor_str(str1, str2, length): + #print str1, str2, length + output = '' + for i in range(length): + output += chr(ord(str1[i]) ^ ord(str2[i])) + return output + +with open(sys.argv[1]) as f: + buf = f.read() + +output = '' +for i in range(0, len(buf), key_len): + #print i + str1 = buf[i: i + key_len] + str2 = buf[i + key_len: i + key_len * 2] + output += xor_str(str1, str2, min(len(str1), len(str2))) +print output + diff --git a/crypto/xor_enc.py b/crypto/xor_enc.py new file mode 100644 index 0000000..14c8a0f --- /dev/null +++ b/crypto/xor_enc.py @@ -0,0 +1,14 @@ +import sys + +crypto = sys.argv[2] +with open(sys.argv[1]) as f: + buf = f.read() + +output = '' +i = 0 +for c in buf: + output += chr(ord(c) ^ ord(crypto[i % len(crypto)])) + i += 1 + +sys.stdout.write(output) +