Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add encryptMulti function

ammarahm-ed463ba3754a63
diff --git a/apps/mobile/app/common/database/encryption.js b/apps/mobile/app/common/database/encryption.js
index 05ac18df2..10204fbd6 100644
--- a/apps/mobile/app/common/database/encryption.js
+++ b/apps/mobile/app/common/database/encryption.js
@@ -166,3 +166,24 @@ export async function encrypt(password, data) {
alg: getAlgorithm(7)
};
}
+
+export async function encryptMulti(password, data) {
+ if (!password.password && !password.key) return undefined;
+ if (password.password && password.password === "" && !password.key)
+ return undefined;
+
+ let results = await Sodium.encryptMulti(
+ password,
+ data.map((item) => ({
+ type: "plain",
+ data: item
+ }))
+ );
+
+ return !results
+ ? []
+ : results.map((result) => ({
+ ...result,
+ alg: getAlgorithm(7)
+ }));
+}