def encode_var_int(number):
    """
	Returns a bytearray encoding the given number.
	"""
    buf = bytearray()
    shift = 1
    while True:
        buf.append(number & 127)
        number -= buf[-1]
        if number == 0:
            buf[-1] |= 128
            break
        number -= shift
        number >>= 7
        shift += 7
    return buf
