Want to decrypt a string from file.
But when i use nodejs decipher on the string from fs, it gives the error "Bad input string"
var fs = require('fs');
var crypto = require('crypto');
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-ctr', 'password')
var dec = decipher.update(text,'hex','utf8')
dec += decipher.final('utf8');
return dec;
}
fs.readFile('./file.json', 'utf8', function (err,data) {
if (err) return console.log(err);
console.log(decrypt(data));
});
tried just making a string like this it works
var stringInFile= "encryptedString";
console.log(decrypt(stringInFile));
Tho console.log(data) from fs also gives 'encryptedString'