MCPcopy Create free account
hub / github.com/FuAdmin/fu-admin / AesEncryption

Class AesEncryption

web/src/utils/cipherOld.ts:13–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13export class AesEncryption {
14 private key;
15 private iv;
16
17 constructor(opt: Partial<EncryptionParams> = {}) {
18 const { key, iv } = opt;
19 if (key) {
20 this.key = parse(key);
21 }
22 if (iv) {
23 this.iv = parse(iv);
24 }
25 }
26
27 get getOptions() {
28 return {
29 mode: ECB,
30 padding: pkcs7,
31 iv: this.iv,
32 };
33 }
34
35 encryptByAES(cipherText: string) {
36 return encrypt(cipherText, this.key, this.getOptions).toString();
37 }
38
39 decryptByAES(cipherText: string) {
40 return decrypt(cipherText, this.key, this.getOptions).toString(UTF8);
41 }
42}
43
44export function encryptByBase64(cipherText: string) {
45 return UTF8.parse(cipherText).toString(Base64);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected