Example #1
0
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
Example #2
0
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
Example #3
0
File: bytes.py Project: wy1433/dcdb
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
Example #4
0
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
Example #5
0
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