'XOR a memory region with a key
Args:
- start: start address (Int)
- end: end address (Int)
- key: XOR key (String)
Returns:
- xored memory content (raw bytes)'

def xormem(self, start, end, key):

    mem = self.dumpmem(start, end)
    if (mem is None):
        return None
    if (to_int(key) != None):
        key = hex2str(to_int(key), self.intsize())
    mem = list(bytes_iterator(mem))
    for (index, char) in enumerate(mem):
        key_idx = (index % len(key))
        mem[index] = chr((ord(char) ^ ord(key[key_idx])))
    buf = ''.join([to_binary_string(x) for x in mem])
    bytes = self.writemem(start, buf)
    return buf
