Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crypto-cookie

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-cookie - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

CryptoCookie.js

6

package.json
{
"name": "crypto-cookie",
"version": "0.2.2",
"description": "cryptoCookie",
"main": "cryptoCookie.js",
"version": "0.3.0",
"description": "Crypto Cookie",
"main": "CryptoCookie.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

crypto-cookie
============
```
```js
var cryptoCookie = require('crypto-cookie');
var crypto = require('crypto');
var cookie = new cryptoCookie(req, res, {
var cookie = new CryptoCookie(req, res, [{
algorithm: 'aes-256-cfb',
ivSize: 128,
keys: [
crypto.pbkdf2Sync('pASsWoRD', 'SaLt', 4096, 32),
crypto.pbkdf2Sync('OlDpaSSwoRd', 'sAlt', 4096, 32)
], // ['current Key', 'old Key', ...]
});
key: crypto.pbkdf2Sync('pASsWoRD', 'SaLt', 4096, 32)
}, {
algorithm: 'aes-256-cfb',
ivSize: 128,
key: crypto.pbkdf2Sync('OlDpaSSwoRd', 'sAlt', 4096, 32)
}]);

@@ -17,0 +18,0 @@ // all cookies

var http = require('http');
var url = require('url');
var cryptoCookie = require('./cryptoCookie');
var CryptoCookie = require('./CryptoCookie');
var crypto = require('crypto');
var server = http.createServer(function(req, res) {
var cookie = new cryptoCookie(req, res, {
var cookie = new CryptoCookie(req, res, [{
algorithm: 'aes-256-cfb',
ivSize: 128,
keys: [crypto.pbkdf2Sync('pASsWoRD', 'SaLt', 4096, 32), crypto.pbkdf2Sync('OlDpaSSwoRd', 'sAlt', 4096, 32)]
});
key: crypto.pbkdf2Sync('pASsWoRD', 'SaLt', 4096, 32)
}, {
algorithm: 'aes-256-cfb',
ivSize: 128,
key: crypto.pbkdf2Sync('OlDpaSSwoRd', 'sAlt', 4096, 32)
}]);
var cookie2 = new CryptoCookie(req, res,[{
algorithm: 'aes-256-cfb',
ivSize: 128,
key: crypto.pbkdf2Sync('newPasSword', 'sAlt', 4096, 32)
}, {
algorithm: 'aes-256-cfb',
ivSize: 128,
key: crypto.pbkdf2Sync('pASsWoRD', 'SaLt', 4096, 32)
}]);
var urlInfo = url.parse(req.url);

@@ -18,11 +32,11 @@

cookie.set('foo', '1', {
cookie.set('foo', 'foooo', {
maxAge: 3600,
httponly: true
});
cookie.set('bar', '2', {
cookie.set('secret', 'this is a secret message', {
encrypt: true,
});
cookie.set('名字', '值');
cookie.set('秘密', '呵呵', {
cookie.set('名字', '蒋凤鸣');
cookie.set('秘密', '这是一条秘密消息', {
encrypt: true

@@ -34,5 +48,7 @@ });

console.log(cookie.get('foo'));
console.log(cookie.get('bar', true));
console.log(cookie.get('secret', true));
console.log(cookie2.get('secret', true));
console.log(cookie.get('名字'));
console.log(cookie.get('秘密', true));
console.log(cookie2.get('秘密', true));

@@ -39,0 +55,0 @@ res.end();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc