From 99edb733d037694b4923383f1e4e412eadc137dc Mon Sep 17 00:00:00 2001 From: Tben Date: Sun, 13 Aug 2023 11:58:33 +0100 Subject: [PATCH] Upgrades --- functions/decrypt.js | 14 ++++++++++---- package.json | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/functions/decrypt.js b/functions/decrypt.js index c1da482..971116c 100644 --- a/functions/decrypt.js +++ b/functions/decrypt.js @@ -2,19 +2,24 @@ const { scryptSync, createDecipheriv } = require("crypto"); const { Buffer } = require("buffer"); const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { - const algorithm = "aes-192-cbc"; - const password = encryptionKey; + if (!encryptedString?.match(/.}/)) { + console.log("Encrypted string is invalid"); + return data; + } 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); + const algorithm = "aes-192-cbc"; + + let key = scryptSync(encryptionKey, encryptionSalt, 24); let iv = Buffer.alloc(16, 0); const decipher = createDecipheriv(algorithm, key, iv); @@ -24,9 +29,10 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { return decrypted; } catch (error) { console.log("Error in decrypting =>", error.message); + console.log("encryptedString =>", encryptedString); console.log("encryptionKey =>", encryptionKey); console.log("encryptionSalt =>", encryptionSalt); - return null; + return data; } }; diff --git a/package.json b/package.json index 75b7316..5738ab9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.6.4", + "version": "1.6.5", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {