Make a var-string (a var-int with the length, concatenated with the data)
    Return the hex-encoded string

def make_var_string(string):
    """
    Make a var-string (a var-int with the length, concatenated with the data)
    Return the hex-encoded string
    """
    s = None
    if isinstance(string, str) and re.match('^[0-9a-fA-F]*$', string):
        # convert from hex to bin, safely
        s = binascii.unhexlify(string)
    else:
        s = string[:]

    buf = encoding.num_to_var_int(len(s)) + s
    return buf.encode('hex')