Esempio n. 1
0
 def _decrypt(self, text, _id, exception=None):
     text = to_binary(text)
     plain_text = self.cipher.decrypt(base64.b64decode(text))
     padding = byte2int(plain_text, -1)
     content = plain_text[16:-padding]
     xml_length = socket.ntohl(struct.unpack(b'I', content[:4])[0])
     xml_content = to_text(content[4:xml_length + 4])
     from_id = to_text(content[xml_length + 4:])
     if from_id != _id:
         exception = exception or Exception
         raise exception()
     return xml_content
Esempio n. 2
0
 def _decrypt(self, text, _id, exception=None):
     text = to_binary(text)
     plain_text = self.cipher.decrypt(base64.b64decode(text))
     padding = byte2int(plain_text, -1)
     content = plain_text[16:-padding]
     xml_length = socket.ntohl(struct.unpack(b'I', content[:4])[0])
     xml_content = to_text(content[4:xml_length + 4])
     from_id = to_text(content[xml_length + 4:])
     if from_id != _id:
         exception = exception or Exception
         raise exception()
     return xml_content
Esempio n. 3
0
 def decode(cls, decrypted):
     padding = byte2int(decrypted, -1)
     if padding < 1 or padding > 32:
         padding = 0
     return decrypted[:-padding]