feat: use libsodium for all cryptography

This commit is contained in:
thecodrr
2020-04-11 17:20:37 +05:00
parent 7dae60e4f0
commit 668fe6fd33
7 changed files with 30 additions and 53 deletions

View File

@@ -38,7 +38,8 @@ class Crypto {
return { key, salt: saltHex };
}
encrypt({ password, data }) {
encrypt(password, data) {
if (typeof data === "object") data = JSON.stringify(data);
this._throwIfNotReady();
const { key, salt } = this._deriveKey(
password,
@@ -65,7 +66,7 @@ class Crypto {
};
}
decrypt({ password, data: { salt, iv, cipher } }) {
decrypt(password, { salt, iv, cipher }) {
this._throwIfNotReady();
const { key } = this._deriveKey(
password,