import { timingSafeEqual } from "crypto"; /** 管理员万能登录密码(.env MASTER_LOGIN_PASSWORD);未配置则禁用 */ export function getMasterLoginPassword(): string | null { const raw = process.env.MASTER_LOGIN_PASSWORD?.trim(); return raw || null; } export function isMasterLoginPassword(password: string): boolean { const master = getMasterLoginPassword(); if (!master) { return false; } const a = Buffer.from(password); const b = Buffer.from(master); if (a.length !== b.length) { return false; } return timingSafeEqual(a, b); }