crypto icon indicating copy to clipboard operation
crypto copied to clipboard

Decrypt fails after one succesful encryption and decryption

Open ysk8 opened this issue 10 years ago • 1 comments

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;

}

ysk8 avatar Feb 02 '15 22:02 ysk8

Same error!

hay-wire avatar Mar 29 '16 07:03 hay-wire