I am trying to decrypt a file content using node-forge aes-cbc but the result is empty **
Actual text: "helloNoor" Aes Result : Decrypted Text Hex
Decrypted Text Bytes
** Here is my code
trying to decrypt the content using aes-cbc by providing key, iv and encrypted content but the output is empty.
var encryptedData = decodedText.substring(288, decodedText.length); //Seperating Encrypted Data
// encryptedData = Buffer.from(encryptedData);
console.log("Encrypted Text\n" + encryptedData);
// The cipher-block chaining mode of operation maintains internal
// state, so to decrypt a new instance must be instantiated.
// var aesCbc = new aesjs.ModeOfOperation.cbc(key, IV);
// var decryptedBytes = aesCbc.decrypt(encryptedData);
// console.log(decryptedBytes.toString());
var decipher = forge.cipher.createDecipher('AES-CBC', key);
decipher.start({
iv: IV
});
decipher.update(forge.util.createBuffer(encryptedData));
decipher.finish();
// console.log(decipher.output.toString());
//var decryptedText = decipher.output.getBytes();
// var nodeBuffer = new Buffer.from(decipher.output.getBytes(), 'binary');
// console.log("Decrypted Buffer\n" + nodeBuffer.toString("utf8"));
console.log("Decrypted Text Hex\n" + decipher.output.toHex());
console.log("Decrypted Text Bytes\n" + decipher.output.getBytes());
via Syed Noorullah