Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
442 views
in Technique[技术] by (71.8m points)

node.js - Can't decrypt a file in NodeJS aes-128-cbc

I want to decrypt a file in nodejs, and I have this function so far :

var fileDecrypt = function(inputFile, outputfile, password) {
      var algorithm = 'aes-128-cbc';
      var data = fs.readFileSync(inputFile, {encoding:'base64'});
      const iv = "SKYGEDANNECY1234"
      console.log(data);
      var decipher = crypto.createDecipheriv(algorithm,Buffer(password, 'hex'),Buffer.from(iv, 'hex'));
      decipher.setAutoPadding(false);
      var dec = decipher.update(data,'base64','utf-8');
      dec += decipher.final();
      console.log(dec);
    },

The problem is when I run it I get this error :

Crypt error

When am I doing wrong here ?

question from:https://stackoverflow.com/questions/65887330/cant-decrypt-a-file-in-nodejs-aes-128-cbc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...