def bytes_to_num(buf):
    """ 
    Convert multibyte buffer into an integer value.  Bytes must be in
    little-endian order.  This function pays no attention to overflow,
    etc.

    :param buf: bytes to convert.
    :returns: integer value.
    """
    val = 0
    for i in range(len(buf) - 1, -1, -1):
        val = val*256 + ord(buf[i])
    return val