#!/usr/bin/env python3

from __future__ import print_function
import sys, struct

KEYLEN=2

def xor_strings(s,t):
    # https://en.wikipedia.org/wiki/XOR_cipher#Example_implementation
    """xor two strings together"""
    return b"".join(bytes([a^b]) for a,b in zip(s,t))

def read_file(fname):
    file=open(fname, mode='rb')
    content=file.read()
    file.close()
    return content

def chunks(l, n):
    """divide input buffer by n-len chunks"""
    n = max(1, n)
    return [l[i:i + n] for i in range(0, len(l), n)]

cipher_file=read_file(sys.argv[1])

k=29 # current state of k
for c in cipher_file:
    if c>=0x20:
        sys.stdout.write (chr(c^k))
    else:
        sys.stdout.write (chr(c)) # skip unencrypted parts
    if k==29:
        k=15
    elif k==15:
        k=29

