import math


def xor_string(string, key):
    """XOR a string with a provided key."""

    # adjust the key lenght to be at least the size of the string
    key_min_len = int(math.ceil(float(len(string)) / float(len(key)))) 

    # xor characters
    return ''.join(chr(ord(s)^ord(k)) for s,k in zip(string, key * key_min_len))