1
0
forked from baron/baron-sso

fix: adminfront utils.ts 내 generateSecurePassword 함수 추가

This commit is contained in:
2026-03-25 15:46:11 +09:00
parent 7c21e500d6
commit c244917737

View File

@@ -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;
}