def decrypt_data(encryption_key_bundle, payload): from binascii import unhexlify from base64 import b64decode crypted_data = json.loads(payload) cipher = AESCipher(key = encryption_key_bundle, iv = crypted_data['IV'], HMAC = unhexlify(crypted_data['hmac']) ) decrypted_data = cipher.instantdecrypt(b64decode(crypted_data['ciphertext'])) return json.loads(decrypted_data.decode())