def bytes_to_number(b, endian='<STR_LIT>'):
if endian == '<STR_LIT>':<EOL><INDENT>b = reversed(b)<EOL><DEDENT>n = <NUM_LIT:0><EOL>for i, ch in enumerate(bytearray(b)):<EOL><INDENT>n ^= ch << i * <NUM_LIT:8><EOL><DEDENT>return n<EOL>
Convert a string to an integer.

:param b:
    String or bytearray to convert.

:param endian:
    Byte order to convert into ('big' or 'little' endian-ness, default
    'big')

Assumes bytes are 8 bits.

This is a special-case version of string_to_number with a full base-256
ASCII alphabet. It is the reverse of ``number_to_bytes(n)``.

Examples::

    >>> bytes_to_number(b'*')
    42
    >>> bytes_to_number(b'\\xff')
    255
    >>> bytes_to_number(b'\\x01\\x00')
    256
    >>> bytes_to_number(b'\\x00\\x01', endian='little')
    256