forked from baron/baron-sso
fix: adminfront utils.ts 내 generateSecurePassword 함수 추가
This commit is contained in:
@@ -4,3 +4,22 @@ import { twMerge } from "tailwind-merge";
|
|||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user