MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / AesEncryptionLibrary

Class AesEncryptionLibrary

app/core/Encryptor/lib.ts:20–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20class AesEncryptionLibrary implements EncryptionLibrary {
21 deriveKey = async (
22 password: string,
23 salt: string,
24 opts: KeyDerivationOptions,
25 ): Promise<string> => {
26 checkForKDFAlgorithm(opts.algorithm);
27
28 return await Aes.pbkdf2(
29 password,
30 salt,
31 opts.params.iterations,
32 SHA256_DIGEST_LENGTH,
33 );
34 };
35
36 generateIV = async (size: number): Promise<string> =>
37 // Naming isn't perfect here, but this is how the library generates random IV (and encodes it the right way)
38 // See: https://www.npmjs.com/package/react-native-aes-crypto#example
39 await Aes.randomKey(size);
40
41 encrypt = async (data: string, key: string, iv: unknown): Promise<string> =>
42 await Aes.encrypt(data, key, iv);
43
44 decrypt = async (data: string, key: string, iv: unknown): Promise<string> =>
45 await Aes.decrypt(data, key, iv);
46}
47
48class AesForkedEncryptionLibrary implements EncryptionLibrary {
49 deriveKey = async (

Callers

nothing calls this directly

Calls 3

checkForKDFAlgorithmFunction · 0.85
encryptMethod · 0.65
decryptMethod · 0.65

Tested by

no test coverage detected