Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

688 B
Raw Blame
import { parentPort } from 'node:worker_threads';
import { compareSync, hashSync } from 'bcryptjs';

export type HashJob =
  | { id: number; op: 'hash'; plain: string; rounds: number }
  | { id: number; op: 'compare'; plain: string; hash: string };

export type HashReply =
  | { id: number; ok: true; value: string | boolean }
  | { id: number; ok: false };

parentPort?.on('message', (job: HashJob) => {
  let reply: HashReply;
  try {
    const value =
      job.op === 'hash' ? hashSync(job.plain, job.rounds) : compareSync(job.plain, job.hash);
    reply = { id: job.id, ok: true, value };
  } catch {
    reply = { id: job.id, ok: false };
  }
  parentPort?.postMessage(reply);
});