From 76bb51b41c051ced66617d91c1e7081aecf83b8b Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 14:28:00 +0200 Subject: [PATCH 1/6] More node version for testing --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 481ae64..43d9a52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,8 @@ language: node_js node_js: - - '5.0' + - '4.8.4' + - '5.5.0' + - '5.12.0' + - '6.0.0' +git: + depth: 3 From c2a2cc268deafe1b5efdeac64018fbe3feb3a9a2 Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 15:36:32 +0200 Subject: [PATCH 2/6] Fixinig (breaking) change in default encoding of crypto lib methods from node >=6.0.0 --- hmacSha1.js | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hmacSha1.js b/hmacSha1.js index c2caf48..4f81580 100644 --- a/hmacSha1.js +++ b/hmacSha1.js @@ -28,9 +28,11 @@ catch(err){ var opad_key = ""; // outer padded key var ipad_key = ""; // inner padded key - var kLen = (enc === 'latin-1' || enc === 'utf8') ? this.asciiOnly(key) : key.length; // enforce ascii in + + if(!enc) enc = 'binary'; // fix for node versions >=6.0.0, in which default encoding is changed to utf-8 + var kLen = (enc === 'latin-1' || enc === 'utf8') ? this.asciiOnly(key) : key.length; // Enforce ascii in // key, only if non ascii - // encoding specified. + // encoding specified. var diff; var hashedKeyLen; diff --git a/package.json b/package.json index ef41f6f..081d6f3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "node ./test/test.js" }, - "engines": {"node": ">=0.1.92"}, + "engines": {"node": "<6.0.0"}, "author": { "name":"gits2501", "email":"telhurat@hotmail.com", From f0d3f6e87adb16a804c79297f95fec3c7afc4595 Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 15:52:09 +0200 Subject: [PATCH 3/6] Better test coverage of node versions --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 43d9a52..33f9ca7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,6 @@ node_js: - '5.5.0' - '5.12.0' - '6.0.0' + - '8.6.0' git: depth: 3 From 2f2abda11883be0398711f8f5bf68908f18ed8fb Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 15:59:01 +0200 Subject: [PATCH 4/6] Changing sha1 definition to reflect default encoding change --- hmacSha1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hmacSha1.js b/hmacSha1.js index 4f81580..c763aec 100644 --- a/hmacSha1.js +++ b/hmacSha1.js @@ -5,6 +5,7 @@ try{ crypto = require('crypto'); sha1 = function(key,enc, format){ + if(!enc) enc = 'binary'; // fix for node versions >=6.0.0, in which default encoding is changed to utf-8 var hash = crypto.createHash('sha1'); // create instance of sha1 hash.update(key, enc); // feed data to it, specify encoding format = format || 'hex'; // defaults to hex, @@ -29,7 +30,6 @@ catch(err){ var opad_key = ""; // outer padded key var ipad_key = ""; // inner padded key - if(!enc) enc = 'binary'; // fix for node versions >=6.0.0, in which default encoding is changed to utf-8 var kLen = (enc === 'latin-1' || enc === 'utf8') ? this.asciiOnly(key) : key.length; // Enforce ascii in // key, only if non ascii // encoding specified. From fbd0ff69ffeb06595d6e29211cd9f6d10dae0f6a Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 16:00:57 +0200 Subject: [PATCH 5/6] Changing sha1 definition to reflect default encoding change --- hmacSha1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hmacSha1.js b/hmacSha1.js index c763aec..2af5e18 100644 --- a/hmacSha1.js +++ b/hmacSha1.js @@ -5,7 +5,8 @@ try{ crypto = require('crypto'); sha1 = function(key,enc, format){ - if(!enc) enc = 'binary'; // fix for node versions >=6.0.0, in which default encoding is changed to utf-8 + enc = enc || 'binary'; // Fix for node versions >=6.0.0, in which default encoding is + // changed to utf-8. var hash = crypto.createHash('sha1'); // create instance of sha1 hash.update(key, enc); // feed data to it, specify encoding format = format || 'hex'; // defaults to hex, From 9d5bca097d18ff1aa89d3d1a51a9b312303f7d3a Mon Sep 17 00:00:00 2001 From: gits2501 Date: Thu, 28 Sep 2017 16:02:46 +0200 Subject: [PATCH 6/6] Changing sha1 definition to reflect default encoding change --- hmacSha1.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hmacSha1.js b/hmacSha1.js index 2af5e18..91c1eb2 100644 --- a/hmacSha1.js +++ b/hmacSha1.js @@ -5,12 +5,12 @@ try{ crypto = require('crypto'); sha1 = function(key,enc, format){ - enc = enc || 'binary'; // Fix for node versions >=6.0.0, in which default encoding is + enc = enc || 'binary'; // Fix for node versions >=6.0.0, in which default encoding is // changed to utf-8. - var hash = crypto.createHash('sha1'); // create instance of sha1 - hash.update(key, enc); // feed data to it, specify encoding - format = format || 'hex'; // defaults to hex, - return hash.digest(format); // return result specified format + format = format || 'hex'; // Defaults to hex + var hash = crypto.createHash('sha1'); // Create instance of sha1 + hash.update(key, enc); // Feed data to it, specify encoding + return hash.digest(format); // Return result specified format } }