feat: initial release of NASG
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
export async function copyToClipboard(
|
||||
value: string,
|
||||
setFlag: (b: boolean) => void,
|
||||
label?: string
|
||||
) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setFlag(true);
|
||||
toast.success(label ? `${label} copied!` : "Copied!", {
|
||||
id: label ? `copy-${label}` : "copy",
|
||||
duration: 1200,
|
||||
});
|
||||
setTimeout(() => setFlag(false), 1200);
|
||||
} catch {
|
||||
toast.error("Error during copying");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user