mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-08 03:27:20 +00:00
14 lines
450 B
TypeScript
14 lines
450 B
TypeScript
import { Pool, spawn, Worker } from "threads";
|
|
import { env } from "../env.js";
|
|
import "../threadsSignalFix.js";
|
|
import { MINUTES } from "../utils.js";
|
|
|
|
const pool = Pool(() => spawn(new Worker("./cryptWorker"), { timeout: 10 * MINUTES }), 8);
|
|
|
|
export async function encrypt(data: string) {
|
|
return pool.queue((w) => w.encrypt(data, env.KEY));
|
|
}
|
|
|
|
export async function decrypt(data: string) {
|
|
return pool.queue((w) => w.decrypt(data, env.KEY));
|
|
}
|