How to use the wilson/conf.settings.SECRET_KEY function in wilson

To help you get started, we’ve selected a few wilson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisdickinson / wilson / lib / contrib / sessions / models.js View on Github external
'get_encoded':function(data) {
        var pickled = JSON.stringify(data),
            md5 = crypto.createHash('md5').update(pickled + settings.SECRET_KEY).digest('hex'),
            result = new Buffer(pickled + md5, 'utf8').toString('base64');
        return result;
    },
    'get_decoded':function() {
github chrisdickinson / wilson / lib / contrib / sessions / backends / base.js View on Github external
SessionStore.prototype.encode = function(data) {
    var pickled = JSON.stringify(data),
        md5 = crypto.createHash('md5').update(pickled + settings.SECRET_KEY).digest('hex'),
        result = new Buffer(pickled + md5, 'utf8').toString('base64');
    return result;
};
github chrisdickinson / wilson / lib / contrib / sessions / models.js View on Github external
'get_decoded':function() {
        var encodedData = (new Buffer(this.session_data, 'base64')).toString('utf8'),
            pickled = encodedData.slice(0, -32),
            tamperCheck = encodedData.slice(-32),
            md5sum = crypto.createHash('md5').update(pickled + settings.SECRET_KEY).digest('hex');
        if(md5sum !== tamperCheck) {
            throw new Error("User tampered with session cookie.");
        } else {
            try {
                return JSON.parse(pickled);
            } catch(err) {
                return {};
            }
        }
    }
});
github chrisdickinson / wilson / lib / contrib / sessions / backends / base.js View on Github external
SessionStore.prototype.getNewSessionKey = function() {
    return crypto.createHash('md5').update([
          random(0, MAX_SESSION_KEY)
        , parseInt(new Date())
        , settings.SECRET_KEY].join('')).digest('hex');
};