Open riddhidoshiv opened 4 years ago
keyLength = keyLength || 32;
let cypher = "aes-" + keyLength * 8 + "-cbc";
//Get session object
laravelSession = new Buffer(laravelSession, "base64");
laravelSession = laravelSession.toString();
laravelSession = JSON.parse(laravelSession);
//Create key buffer
laravelKey = new Buffer(laravelKey, "base64");
//crypto required iv in binary or buffer
laravelSession.iv = new Buffer(laravelSession.iv, "base64");
//create decoder
let decoder = crypto.createDecipheriv(cypher, laravelKey, laravelSession.iv);
//add data to decoder and return decoded
let decoded = decoder.update(laravelSession.value, "base64", "utf8");
//get last characters from decoded and concatenate to session data
let pad = decoder.final("utf8");
let data = decoded+pad
// value not serialized in Laravel 5.5+
// use heuristic to choose whether deserialization is needed
let id = /^s:\d+:".*";/.test(data) ? unserialize(data) : data;
id = id.split("|");
return id[1];
Hello @rouve and thanks for that fix !
It's working pretty well on my local machine but not on a debian VPS. Any idea why it wouldn't work there ?
It's throwing me a ERR_OSSL_EVP_BAD_DECRYPT and decoded looks like that :
decoded = ����_Xי�1|6Su����I�>Dl�qϦ�=p+���!�^p�WVI��� ؐ�2�F�Z�piF>��7Z��˼�SP5
Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Could it be an openssl version problem that affects crypto.createDecipheriv in your opinion ? Thanks for any advice !
No need for an answer, it was just a bad key on my VPS environment. The error message isn't really specific..
SyntaxError: Unknown / Unhandled data type(s): e at error (../node_modules/php-unserialize/php-unserialize.js:54:13) at _unserialize (../node_modules/php-unserialize/php-unserialize.js:166:11) at unserialize (../node_modules/php-unserialize/php-unserialize.js:173:10) at Object.getSessionKey (../node_modules/node-laravel-session/index.js:46:16) at../middleware/userMiddleware.js:19:40
laravel_session : eyJpdiI6Ik9WcC9yUGhmeERoaVdZZUNuLzJ5dkE9PSIsInZhbHVlIjoiWERRMlJNd29pTXFMbHV5Wnl6TTMweG9WcUtDNC9BSFQxZXZFS0FnTnVpOVNMS0E0RExDWW1VVFdKa3JsNjRLTyIsIm1hYyI6ImNhM2RlYTUzZmMyMzUxMTUyYWZmYjg0NGFjNjkyNTUxNTZhYjk0MWVkZGY1NTBhNjgwMTk3ZjZiZDg0Y2UxYTUifQ== app_key : h/UqrS2DWcqVGc+Joj8gQwXc03bq9Vt2NXDji/wbqQA i pass all data perfectly but it throws error i spent too much time but i did not find any solution