From feb28acf65e04e4ede150d477fa9d6fda40052b0 Mon Sep 17 00:00:00 2001 From: pipcat Date: Sun, 20 May 2018 19:30:34 +0200 Subject: [PATCH] =?UTF-8?q?correcci=C3=B3n=20librer=C3=ADa=20crypto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/pelispedia.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugin.video.alfa/channels/pelispedia.py b/plugin.video.alfa/channels/pelispedia.py index 23a6e6f7..fa8282d5 100644 --- a/plugin.video.alfa/channels/pelispedia.py +++ b/plugin.video.alfa/channels/pelispedia.py @@ -698,8 +698,7 @@ def evpKDF(passwd, salt, key_size=8, iv_size=4, iterations=1, hash_algorithm="md } def obtener_cripto(password, plaintext): - import hashlib, os, base64, json - from Crypto.Cipher import AES + import os, base64, json SALT_LENGTH = 8 BLOCK_SIZE = 16 KEY_SIZE = 32 @@ -712,8 +711,15 @@ def obtener_cripto(password, plaintext): kdf = evpKDF(password, salt) - cipherSpec = AES.new(kdf['key'], AES.MODE_CBC, iv) - ciphertext = cipherSpec.encrypt(paddedPlaintext) + try: # Intentar con librería AES del sistema + from Crypto.Cipher import AES + cipherSpec = AES.new(kdf['key'], AES.MODE_CBC, iv) + ciphertext = cipherSpec.encrypt(paddedPlaintext) + + except: # Si falla intentar con librería del addon + import jscrypto + cipherSpec = jscrypto.new(kdf['key'], jscrypto.MODE_CBC, iv) + ciphertext = cipherSpec.encrypt(paddedPlaintext) return json.dumps({'ct': base64.b64encode(ciphertext), 'iv': iv.encode("hex"), 's': salt.encode("hex")}, sort_keys=True, separators=(',', ':'))