Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
cookie-encrypter
Advanced tools
Express middleware to use with cookie-parser.
Transparently encrypt and decrypt cookies with req.cookies
(populated by cookie-parser).
Support all cookies (including http-only and signed) with string content or JSON.
Use aes256
as the default encryption algorithm.
$ npm install cookie-encrypter
var express = require('express');
var cookieParser = require('cookie-parser');
var cookieEncrypter = require('cookie-encrypter');
var secretKey = 'foobarbaz12345';
var app = express();
app.use(cookieParser(secretKey));
app.use(cookieEncrypter(secretKey));
secret
a string or array used for encrypting cookies.options
an optional object to set options for encryption.options.algorithm
algorithm used to encrypt cookie data (any algorithm supported by OpenSSL). aes256
used as the default one.Encrypt a cookie value and return it. An options.algorithm
can optionaly be passed to specify an algorithm to use for the encryption.
Decrypt a cookie value and return it. An options.algorithm
can optionaly be passed to specify an algorithm to use for the decryption.
var express = require('express');
var cookieParser = require('cookie-parser');
var cookieEncrypter = require('cookie-encrypter');
var secretKey = 'foobarbaz12345';
var app = express();
app.use(cookieParser(secretKey));
app.use(cookieEncrypter(secretKey));
app.get('/setcookies', function(req, res) {
const cookieParams = {
httpOnly: true,
signed: true,
maxAge: 300000,
};
res.cookie('supercookie', 'my data is encrypted', cookieParams);
// OR ALTERNATIVELY
// res.cookie('supercookie', { myData: 'is encrypted' }, cookieParams);
res.end('new cookie set (supercookie)');
})
app.get('/getcookies', function(req, res) {
console.log("Decrypted cookies: ", req.cookies)
});
app.listen(8080);
FAQs
Transparently encrypt/decrypt your cookie with Nodejs
The npm package cookie-encrypter receives a total of 0 weekly downloads. As such, cookie-encrypter popularity was classified as not popular.
We found that cookie-encrypter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.