def evp_decode(cipher_text, passphrase, salt=None): cipher_text = base64.b64decode(cipher_text) if not salt: salt = cipher_text[8:16] cipher_text = cipher_text[16:] data = evpKDF(passphrase, salt) decrypter = pyaes.Decrypter( pyaes.AESModeOfOperationCBC(data['key'], data['iv'])) plain_text = decrypter.feed(cipher_text) plain_text += decrypter.feed() return plain_text
def gk_decrypt(name, 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: logger.log( 'Exception (%s) during %s gk decrypt: cipher_link: %s' % (e, name, cipher_link), log_utils.LOGWARNING) plain_text = '' return plain_text
def __decrypt(self, message, key, iv): decrypter = pyaes.Decrypter(pyaes.AESModeOfOperationCBC(key, iv)) plain_text = decrypter.feed(message) plain_text += decrypter.feed() plain_text = plain_text.split('\0', 1)[0] return plain_text