Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #714 from mdp/master

Replace 'node-crc' with MIT licensed 'buffer-crc32'
  • Loading branch information...
commit 5f612983d1543a52bec025b9bfb60fceee4c578f 2 parents 3055802 + fe6ba40
TJ Holowaychuk tj authored
6 lib/middleware/cookieSession.js
View
@@ -13,7 +13,7 @@ var utils = require('./../utils')
, Cookie = require('./session/cookie')
, debug = require('debug')('connect:cookieSession')
, signature = require('cookie-signature')
- , crc16 = require('crc').crc16;
+ , crc32 = require('buffer-crc32');
/**
* Cookie Session:
@@ -71,7 +71,7 @@ module.exports = function cookieSession(options){
if (rawCookie) {
var unsigned = utils.parseSignedCookie(rawCookie, secret);
if (unsigned) {
- var originalHash = crc16(unsigned);
+ var originalHash = crc32.signed(unsigned);
req.session = utils.parseJSONCookie(unsigned) || {};
}
}
@@ -101,7 +101,7 @@ module.exports = function cookieSession(options){
var val = 'j:' + JSON.stringify(req.session);
// compare hashes, no need to set-cookie if unchanged
- if (originalHash == crc16(val)) return debug('unmodified session');
+ if (originalHash == crc32.signed(val)) return debug('unmodified session');
// set-cookie
val = 's:' + signature.sign(val, secret);
4 lib/middleware/session.js
View
@@ -18,7 +18,7 @@ var Session = require('./session/session')
, Store = require('./session/store')
, utils = require('./../utils')
, parse = utils.parseUrl
- , crc16 = require('crc').crc16;
+ , crc32 = require('buffer-crc32');
// environment
@@ -346,7 +346,7 @@ function session(options){
*/
function hash(sess) {
- return crc16(JSON.stringify(sess, function(key, val){
+ return crc32.signed(JSON.stringify(sess, function(key, val){
if ('cookie' != key) return val;
}));
}
2  package.json
View
@@ -9,7 +9,7 @@
"qs": "0.5.1",
"formidable": "1.0.11",
"cookie-signature": "0.0.1",
- "crc": "0.2.0",
+ "buffer-crc32": "0.1.1",
"cookie": "0.0.5",
"bytes": "0.0.1",
"send": "0.1.0",
Please sign in to comment.
Something went wrong with that request. Please try again.