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

Class AesEncryption

web/src/utils/cipher.ts:27–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27class AesEncryption implements Encryption {
28 private readonly key;
29 private readonly iv;
30
31 constructor({ key, iv }: EncryptionParams) {
32 this.key = parse(key);
33 this.iv = parse(iv);
34 }
35
36 get getOptions() {
37 return {
38 mode: CTR,
39 padding: pkcs7,
40 iv: this.iv,
41 };
42 }
43
44 encrypt(plainText: string) {
45 return aesEncrypt(plainText, this.key, this.getOptions).toString();
46 }
47
48 decrypt(cipherText: string) {
49 return aesDecrypt(cipherText, this.key, this.getOptions).toString(UTF8);
50 }
51}
52
53// Define a singleton class for Base64 encryption
54class Base64Encryption implements Encryption {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected