Upgrades
This commit is contained in:
parent
ee16e28597
commit
99edb733d0
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user