Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
cookie-encrypter
Advanced tools
Transparently encrypt/decrypt your cookie using an express middleware to set after the cookie-parser.
Support all type of cookie (including http-only and signed) with string content or JSON.
Use aes256
as the default encryption algorithm (internally use the nodejs crypto module).
$ npm install cookie-encrypter
Easy to use:
const express = require('express');
const cookieParser = require('cookie-parser');
const cookieEncrypter = require('./cook');
const app = express();
const secretKey = 'foobarbaz12345';
app.use(cookieParser(secretKey));
app.use(cookieEncrypter(secretKey));
app.get('/setcookies', function(req, res) {
const cookieParams = {
httpOnly: true,
signed: true,
maxAge: 300000,
};
// Set encrypted cookies
res.cookie('supercookie', 'my text is encrypted', cookieParams);
res.cookie('supercookie2', { myData: 'is encrypted' }, cookieParams);
// You can still set plain cookies
res.cookie('plaincookie', 'my text is plain', { plain: true });
res.cookie('plaincookie2', { myData: 'is plain' }, { plain: true });
res.end('new cookies set');
})
app.get('/getcookies', function(req, res) {
console.log('Decrypted cookies: ', req.signedCookies)
console.log('Plain cookies: ', req.cookies)
});
You can find a ready-to-use example here
Think about the npm install
before running it ;)
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.
FAQs
Transparently encrypt/decrypt your cookie with Nodejs
The npm package cookie-encrypter receives a total of 5,758 weekly downloads. As such, cookie-encrypter popularity was classified as 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.