summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/GptForLove.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-23 04:59:46 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-23 04:59:46 +0100
commit6614dfefd17728743f5d3aaab6a1247f588f0513 (patch)
tree6043d1ed8c150d4ace4012c45ad45d1a84d37b28 /g4f/Provider/GptForLove.py
parentFix create copilot comment (diff)
downloadgpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar.gz
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar.bz2
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar.lz
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar.xz
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.tar.zst
gpt4free-6614dfefd17728743f5d3aaab6a1247f588f0513.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/GptForLove.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/g4f/Provider/GptForLove.py b/g4f/Provider/GptForLove.py
index 1529fb70..07e3406f 100644
--- a/g4f/Provider/GptForLove.py
+++ b/g4f/Provider/GptForLove.py
@@ -1,13 +1,7 @@
from __future__ import annotations
from aiohttp import ClientSession
-import json
-from Crypto.Cipher import AES
-from Crypto.Util import Padding
-import base64
-import hashlib
-import time
-import math
+import execjs, os, json
from ..typing import AsyncResult, Messages
from .base_provider import AsyncGeneratorProvider
@@ -71,13 +65,18 @@ class GptForLove(AsyncGeneratorProvider):
def get_secret() -> str:
- 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()
+ dir = os.path.dirname(__file__)
+ include = f'{dir}/npm/node_modules/crypto-js/crypto-js'
+ source = """
+CryptoJS = require({include})
+var k = 'fjfsdwiuhfwf'
+ , 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('')