This commit is contained in:
Tben 2023-08-13 11:58:33 +01:00
parent ee16e28597
commit 99edb733d0
2 changed files with 11 additions and 5 deletions

View File

@ -2,19 +2,24 @@ const { scryptSync, createDecipheriv } = require("crypto");
const { Buffer } = require("buffer"); const { Buffer } = require("buffer");
const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
const algorithm = "aes-192-cbc"; if (!encryptedString?.match(/.}/)) {
const password = encryptionKey; console.log("Encrypted string is invalid");
return data;
}
if (!encryptionKey?.match(/.{8,}/)) { if (!encryptionKey?.match(/.{8,}/)) {
console.log("Decrption key is invalid"); console.log("Decrption key is invalid");
return data; return data;
} }
if (!encryptionSalt?.match(/.{8,}/)) { if (!encryptionSalt?.match(/.{8,}/)) {
console.log("Decrption salt is invalid"); console.log("Decrption salt is invalid");
return data; 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); let iv = Buffer.alloc(16, 0);
const decipher = createDecipheriv(algorithm, key, iv); const decipher = createDecipheriv(algorithm, key, iv);
@ -24,9 +29,10 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
return decrypted; return decrypted;
} catch (error) { } catch (error) {
console.log("Error in decrypting =>", error.message); console.log("Error in decrypting =>", error.message);
console.log("encryptedString =>", encryptedString);
console.log("encryptionKey =>", encryptionKey); console.log("encryptionKey =>", encryptionKey);
console.log("encryptionSalt =>", encryptionSalt); console.log("encryptionSalt =>", encryptionSalt);
return null; return data;
} }
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.6.4", "version": "1.6.5",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {