blob: c3712c1635e5eb0d069fa351d5c146269600d309 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import crypto from "crypto";
const generateAlphanumericString = (length: number) => {
return Array(length)
.fill(0)
.map((x) => Math.random().toString(36).charAt(2))
.join("");
};
export const generateEditToken = () => generateAlphanumericString(32);
export const generateRSAKeypair = () => {
return crypto.generateKeyPairSync("rsa", {
modulusLength: 4096,
publicKeyEncoding: {
type: "spki",
format: "pem",
},
privateKeyEncoding: {
type: "pkcs8",
format: "pem",
},
});
};
|