def bytes_to_num(data):
    """ *data* must be at least 4 bytes long, big-endian order. """
    assert len(data) >= 4
    num = data[3]
    num += data[2] << 8 & 65280
    num += data[1] << 16 & 16711680
    num += data[0] << 24 & 4278190080
    return num
