def DecodeIntDesc(b): if len(b) < 16 : return None, None, error.BaseError("insufficient bytes to decode value") u = int(b[-16:], 16) ^ uint64Mask v = DecodeCmpUintToInt(u) b = b[:-16] return b, v, None
def DecodeIntDesc2(b): if len(b) < 8 : return None, None, error.BaseError("insufficient bytes to decode value") u = struct.unpack(">Q", b[-8:])[0] ^ uint64Mask v = DecodeCmpUintToInt(u) b = b[:-8] return b, v, None
def DecodeBytes(data): ''' @type data: str @rtype: str, str, error @return: left_str, right_str, error ''' info = data.rsplit(b'\0', 1) if len(info) != 2: return None, None, error.BaseError("DecodeBytes err. \0 not found.") else: return info[0], info[1], None
def DecodeUintDesc(b): if len(b) < 16 : return None, None, error.BaseError("insufficient bytes to decode value") u = int(b[-16:], 16) ^ uint64Mask b = b[:-16] return b, u, None
def DecodeUint2(b): if len(b) < 8 : return None, None, error.BaseError("insufficient bytes to decode value") u = struct.unpack(">Q", b[-8:])[0] b = b[:-8] return b, u, None