Exemple #1
0
 def op2bytes(self, mode):
     b_type = self.type.encode()
     b_index = utils.int2bytes(self.index)
     b_index = six.int2byte(len(b_index)) + b_index
     if self.type == 'i':
         b_data = self.data.encode()
     else:
         b_data = utils.int2bytes(self.data)
     return b_type + b_index + b_data
Exemple #2
0
 def encode_header(self):
     ds = []
     ds.append(int2bytes(len(self.interface)))
     ds.append(self.interface)
     ds.append(int2bytes(len(self.method)))
     ds.append(self.method)
     ds.append(int2bytes(len(self.parameter_types_string)))
     ds.append(self.parameter_types_string)
     return ''.join(ds)
Exemple #3
0
def encode_act_key(key):
    ds = []
    ds.append(int2bytes(len(key[0])))
    ds.append(key[0])
    ds.append(int2bytes(len(key[1])))
    ds.append(key[1])
    ds.append(int2bytes(len(key[2])))
    ds.append(key[2])
    return ''.join(ds)
Exemple #4
0
 def oplist2bytes(self, l):
     ret = b''
     for op in l:
         b_op = op.op2bytes(self.mode)
         length = len(b_op)
         b_length = utils.int2bytes(length)
         ret += six.int2byte(len(b_length)) + b_length + b_op
     return ret
Exemple #5
0
def gluechops(chops, key, n, funcref):
    """
    Glues chops back together into a string.  calls
    funcref(integer, key, n) for each chop.

    Used by 'decrypt' and 'verify'.
    """
    message = ""
    chops = unpicklechops(chops)
    for cpart in chops:
        mpart = funcref(cpart, key, n)
        message += utils.int2bytes(mpart)
    return message
Exemple #6
0
def gluechops(chops, key, n, funcref):
    """
    Glues chops back together into a string.  calls
    funcref(integer, key, n) for each chop.

    Used by 'decrypt' and 'verify'.
    """
    message = ""
    chops = unpicklechops(chops)
    for cpart in chops:
        mpart = funcref(cpart, key, n)
        message += utils.int2bytes(mpart)
    return message
Exemple #7
0
 def setpointer(self, value, fout):
     fout.seek(self.pointer)
     bytestring = "".join(map(chr, int2bytes(value, length=2)))
     fout.write(bytestring)
Exemple #8
0
 def encode_body(self):
     ds = []
     ds.append(int2bytes(self.Id))
     ds.append(int2bytes(len(self.result)))
     ds.append(self.result)
     return ''.join(ds)
Exemple #9
0
 def encode_body(self):
     ds = []
     ds.append(int2bytes(self.Id))
     ds.append(int2bytes(len(self.parameter)))
     ds.append(self.parameter)
     return ''.join(ds)
 def setpointer(self, value, fout):
     fout.seek(self.pointer)
     bytestring = bytes(int2bytes(value, length=2))
     fout.write(bytestring)
 def setpointer(self, value, filename):
     f = open(filename, 'r+b')
     f.seek(self.pointer)
     bytestring = "".join(map(chr, int2bytes(value, length=2)))
     f.write(bytestring)
     f.close()