Files
NASG/lib/generateSecret.ts
T

7 lines
213 B
TypeScript
Raw Normal View History

2025-08-20 22:56:16 +02:00
export function generateSecret(bytes = 32): string {
const arr = new Uint8Array(bytes);
crypto.getRandomValues(arr);
let bin = "";
arr.forEach((b) => (bin += String.fromCharCode(b)));
return btoa(bin);
}