Initial commit
This commit is contained in:
commit
7628b18255
94 changed files with 6386 additions and 0 deletions
17
@dasig/scripts/functions/encryptRsa.ts
Normal file
17
@dasig/scripts/functions/encryptRsa.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { JSEncrypt } from "jsencrypt";
|
||||
import * as fs from "node:fs";
|
||||
import * as toml from "toml";
|
||||
|
||||
const config = toml.parse(
|
||||
fs.readFileSync("configs/config.security.toml", "utf-8"),
|
||||
);
|
||||
const enc = new JSEncrypt();
|
||||
const PUBLIC_KEY = config.rsa.public_key;
|
||||
|
||||
export default (message: string) => {
|
||||
enc.setPublicKey(PUBLIC_KEY);
|
||||
const encrypted = enc.encrypt(message).toString();
|
||||
const fixedEncrypted = encrypted.replace(/\//g, "~");
|
||||
|
||||
return fixedEncrypted;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue