crypto-cookie
Advanced tools
Comparing version 0.2.2 to 0.3.0
{ | ||
"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 |
34
test.js
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(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6253
144
42
2