Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Decrypt fails after one succesful encryption and decryption #9

Open
ysk8 opened this issue Feb 2, 2015 · 1 comment
Open

Decrypt fails after one succesful encryption and decryption #9

ysk8 opened this issue Feb 2, 2015 · 1 comment

Comments

@ysk8
Copy link

ysk8 commented Feb 2, 2015

When the user try to authenticate the first time and fail/success, then, try again/logout, the server is stopped and throw this error:

crypto.js:279
var ret = this._binding.update(data, inputEncoding);
^
TypeError: error:00000000:lib(0):func(0):reason(0)
at Decipher.Cipher.update (crypto.js:279:27)

All function well each time restart the app.

The Code:

var algorithm = 'aes-256-cbc';
var inputEncoding = 'utf8';
var outputEncoding = 'hex';

var crypto = require('crypto'),
key = process.env.SUPER_SECRET_KEY,
cipher = crypto.createCipher(algorithm, key),
decipher = crypto.createDecipher(algorithm, key);

exports.cipherData = function(pass){
var encryptedPass = cipher.update(pass, inputEncoding, outputEncoding);
encryptedPass += cipher.final(outputEncoding);

return encryptedPass;

}

exports.decipherData = function(pass){
var decryptedPass = decipher.update(pass, outputEncoding, inputEncoding);
decryptedPass += decipher.final(inputEncoding);
console.log(decryptedPass);

return decryptedPass;

}

@hay-wire
Copy link

Same error!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants