def _gk_decrypt(self, key, cipher_link): try: key += (24 - len(key)) * '\0' decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationECB(key)) plain_text = decrypter.feed(cipher_link.decode('hex')) plain_text += decrypter.feed() plain_text = plain_text.split('\0', 1)[0] except Exception as e: log_utils.log('Exception (%s) during %s gk decrypt: cipher_link: %s' % (e, self.get_name(), cipher_link), log_utils.LOGWARNING) plain_text = '' return plain_text
def __encrypt(self, key, text): encrypter = pyaes.Encrypter(pyaes.AESModeOfOperationECB(key)) ct = encrypter.feed(text) ct += encrypter.feed() return ct
def __decrypt(self, key, cipher_text): decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationECB(key)) plain_text = decrypter.feed(cipher_text) plain_text += decrypter.feed() return plain_text