def _crc11(value):
    """
    >>> print ' '.join(hex(_crc11(USPS_4State('01234567094987654321',x).binary)) for x in ('','01234','012345678','01234567891'))
    0x51 0x65 0x606 0x751
    """
    bytes = hex(int(value))[2:-1]
    bytes = '0' * (26 - len(bytes)) + bytes
    gp = 3893
    fcs = 2047
    data = int(bytes[:2], 16) << 5
    for b in range(2, 8):
        if (fcs ^ data) & 1024:
            fcs = fcs << 1 ^ gp
        else:
            fcs = fcs << 1
        fcs &= 2047
        data <<= 1
    for x in range(2, 2 * 13, 2):
        data = int(bytes[x:x + 2], 16) << 3
        for b in range(8):
            if (fcs ^ data) & 1024:
                fcs = fcs << 1 ^ gp
            else:
                fcs = fcs << 1
            fcs &= 2047
            data <<= 1
    return fcs
