From c2449177375d4d9b3955c247db00bdea882aa574 Mon Sep 17 00:00:00 2001 From: chan Date: Wed, 25 Mar 2026 15:46:11 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20adminfront=20utils.ts=20=EB=82=B4=20gene?= =?UTF-8?q?rateSecurePassword=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminfront/src/lib/utils.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/adminfront/src/lib/utils.ts b/adminfront/src/lib/utils.ts index 365058ce..084e99ce 100644 --- a/adminfront/src/lib/utils.ts +++ b/adminfront/src/lib/utils.ts @@ -4,3 +4,22 @@ import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } + +export function generateSecurePassword(length = 16): string { + const charset = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-="; + let password = ""; + if (typeof crypto !== "undefined" && crypto.getRandomValues) { + const values = new Uint32Array(length); + crypto.getRandomValues(values); + for (let i = 0; i < length; i++) { + password += charset[values[i] % charset.length]; + } + } else { + // Fallback for older environments + for (let i = 0; i < length; i++) { + password += charset[Math.floor(Math.random() * charset.length)]; + } + } + return password; +}