This commit is contained in:
Tben
2023-08-12 17:35:59 +01:00
parent f0feaf508b
commit b5a4de3e8f
7 changed files with 34 additions and 8 deletions
+9
View File
@@ -5,6 +5,15 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
const algorithm = "aes-192-cbc";
const password = encryptionKey;
if (!encryptionKey?.match(/.{8,}/)) {
console.log("Decrption key is invalid");
return data;
}
if (!encryptionSalt?.match(/.{8,}/)) {
console.log("Decrption salt is invalid");
return data;
}
let key = scryptSync(password, encryptionSalt, 24);
let iv = Buffer.alloc(16, 0);
const decipher = createDecipheriv(algorithm, key, iv);