7 lines
213 B
TypeScript
7 lines
213 B
TypeScript
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);
|
|
} |