summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-11-18 12:24:39 +0100
committerGitHub <noreply@github.com>2023-11-18 12:24:39 +0100
commit2fcb3f949bbde7f5380acc68dc6b1f938dec12bc (patch)
tree035bd400b4057a744b29a0ebee96579bfbf429f6 /g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js
parent~ | g4f `v-0.1.8.5` (diff)
parentAdd AiChatOnline, ChatgptDemoAi, ChatgptNext Providers (diff)
downloadgpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar.gz
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar.bz2
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar.lz
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar.xz
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.tar.zst
gpt4free-2fcb3f949bbde7f5380acc68dc6b1f938dec12bc.zip
Diffstat (limited to 'g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js')
-rw-r--r--g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js b/g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js
deleted file mode 100644
index 67cd671c..00000000
--- a/g4f/Provider/npm/node_modules/funcaptcha/lib/crypt.js
+++ /dev/null
@@ -1,51 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const crypto_1 = require("crypto");
-function encrypt(data, key) {
- let salt = "";
- let salted = "";
- let dx = Buffer.alloc(0);
- // Generate salt, as 8 random lowercase letters
- salt = String.fromCharCode(...Array(8).fill(0).map(_ => Math.floor(Math.random() * 26) + 97));
- // Our final key and iv come from the key and salt being repeatedly hashed
- // dx = md5(md5(md5(key + salt) + key + salt) + key + salt)
- // For each round of hashing, we append the result to salted, resulting in a 96 character string
- // The first 64 characters are the key, and the last 32 are the iv
- for (let x = 0; x < 3; x++) {
- dx = (0, crypto_1.createHash)("md5")
- .update(Buffer.concat([
- Buffer.from(dx),
- Buffer.from(key),
- Buffer.from(salt),
- ]))
- .digest();
- salted += dx.toString("hex");
- }
- let aes = (0, crypto_1.createCipheriv)("aes-256-cbc", Buffer.from(salted.substring(0, 64), "hex"), // Key
- Buffer.from(salted.substring(64, 64 + 32), "hex") // IV
- );
- return JSON.stringify({
- ct: aes.update(data, null, "base64") + aes.final("base64"),
- iv: salted.substring(64, 64 + 32),
- s: Buffer.from(salt).toString("hex"),
- });
-}
-function decrypt(rawData, key) {
- let data = JSON.parse(rawData);
- // We get our decryption key by doing the inverse of the encryption process
- let dk = Buffer.concat([Buffer.from(key), Buffer.from(data.s, "hex")]);
- let arr = [Buffer.from((0, crypto_1.createHash)("md5").update(dk).digest()).toString("hex")];
- let result = arr[0];
- for (let x = 1; x < 3; x++) {
- arr.push(Buffer.from((0, crypto_1.createHash)("md5")
- .update(Buffer.concat([Buffer.from(arr[x - 1], "hex"), dk]))
- .digest()).toString("hex"));
- result += arr[x];
- }
- let aes = (0, crypto_1.createDecipheriv)("aes-256-cbc", Buffer.from(result.substring(0, 64), "hex"), Buffer.from(data.iv, "hex"));
- return aes.update(data.ct, "base64", "utf8") + aes.final("utf8");
-}
-exports.default = {
- encrypt,
- decrypt,
-};