UNPKG

@tryforge/forgescript

Version:

ForgeScript is a comprehensive package that empowers you to effortlessly interact with Discord's API. It ensures scripting remains easy to learn and consistently effective.

53 lines 1.62 kB
"use strict"; /* * SPDX-License-Identifier: GPL-3.0-or-later * Copyright © 2025 BotForge */ Object.defineProperty(exports, "__esModule", { value: true }); exports.encrypt = exports.deriveKey = void 0; const crypto_1 = require("crypto"); const structures_1 = require("../../structures"); /** * Provided to FS by lynnux */ const FIXED_IV = Buffer.from("12345678901234567890123456789012", "hex"); function deriveKey(key) { return (0, crypto_1.scryptSync)(key, "salt", 32); } exports.deriveKey = deriveKey; function encrypt(text, key) { const idkhowtocallthis = deriveKey(key); const cipher = (0, crypto_1.createCipheriv)("aes-256-cbc", new Uint8Array(idkhowtocallthis), new Uint8Array(FIXED_IV)); let encrypted = cipher.update(text, "utf-8", "hex"); encrypted += cipher.final("hex"); return encrypted; } exports.encrypt = encrypt; exports.default = new structures_1.NativeFunction({ name: "$encrypt", version: "1.5.0", description: "Encrypts given text with a key", brackets: true, output: structures_1.ArgType.String, args: [ { name: "text", description: "The text to encrypt", rest: false, required: true, type: structures_1.ArgType.String }, { name: "key", description: "The key to use to encrypt text", rest: false, required: true, type: structures_1.ArgType.String } ], unwrap: true, execute(ctx, [text, key]) { return this.success(encrypt(text, key)); } }); //# sourceMappingURL=encrypt.js.map