0

If you're trying to decrypt a string using nodejs, you will get this error if you're not using the proper input encoding and output encoding.

When doing decrypt, the input / output should be reverse of what was used during input.

 var mykey = _crypt.createCipheriv('aes-256-cbc', key, iv);
        var myNom = mykey.update(nom, 'utf8', 'hex')
        myNom += mykey.final('hex');
        console.log("myNom: ", myNom.toString())

1 Answer 1

1

Decrypt phase is the opposite input / output encoding.

 var mykey = _crypt.createDecipheriv('aes-256-cbc', key, iv);
        var myNom = mykey.update(cipheredtextgoeshere, 'hex', 'utf8') //reversed
        myNom += mykey.final('utf8'); //reversed
        console.log("Decrypted: ", myNom.toString())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.