summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/GptForLove.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-13 15:53:53 +0100
committerGitHub <noreply@github.com>2024-01-13 15:53:53 +0100
commit88bfe2ce426258e2cb85072721004b6abdf746ba (patch)
tree44e3827128489f13fd6fbe7d18171d81176abc86 /g4f/Provider/GptForLove.py
parentMerge pull request #1462 from hlohaus/img (diff)
parentMerge branch 'main' into main (diff)
downloadgpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.gz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.bz2
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.lz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.xz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.zst
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.zip
Diffstat (limited to 'g4f/Provider/GptForLove.py')
-rw-r--r--g4f/Provider/GptForLove.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/g4f/Provider/GptForLove.py b/g4f/Provider/GptForLove.py
index 90e2096c..1529fb70 100644
--- a/g4f/Provider/GptForLove.py
+++ b/g4f/Provider/GptForLove.py
@@ -1,7 +1,13 @@
from __future__ import annotations
from aiohttp import ClientSession
-import execjs, os, json
+import json
+from Crypto.Cipher import AES
+from Crypto.Util import Padding
+import base64
+import hashlib
+import time
+import math
from ..typing import AsyncResult, Messages
from .base_provider import AsyncGeneratorProvider
@@ -65,18 +71,13 @@ class GptForLove(AsyncGeneratorProvider):
def get_secret() -> str:
- dir = os.path.dirname(__file__)
- include = f'{dir}/npm/node_modules/crypto-js/crypto-js'
- source = """
-CryptoJS = require({include})
-var k = '14487141bvirvvG'
- , e = Math.floor(new Date().getTime() / 1e3);
-var t = CryptoJS.enc.Utf8.parse(e)
- , o = CryptoJS.AES.encrypt(t, k, {
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
-});
-return o.toString()
-"""
- source = source.replace('{include}', json.dumps(include))
- return execjs.compile(source).call('')
+ k = '14487141bvirvvG'
+ e = math.floor(time.time())
+
+ plaintext = str(e).encode('utf-8')
+ key = hashlib.md5(k.encode('utf-8')).digest()
+
+ cipher = AES.new(key, AES.MODE_ECB)
+ ciphertext = cipher.encrypt(Padding.pad(plaintext, AES.block_size, style='pkcs7'))
+
+ return base64.b64encode(ciphertext).decode()