import struct


def bytes_to_int(bytes, byteorder='big'):
    """Simple helper function to convert byte strings into integers."""
    endian = {'big': '>', 'little': '<'}[byteorder]
    chars = struct.unpack(endian + ('B' * len(bytes)), bytes)
    if byteorder == 'big':
        chars = chars[::-1]
    return sum(int(char) * 256 ** i for (i, char) in enumerate(chars))