Skip to content

Commit

Permalink
More node version for testing (#4)
Browse files Browse the repository at this point in the history
* More node version for testing

* Fixinig (breaking) change in default encoding of crypto lib methods from node >=6.0.0

* Better test coverage of node versions

* Changing sha1 definition to reflect default encoding change

* Changing sha1 definition to reflect default encoding change

* Changing sha1 definition to reflect default encoding change
  • Loading branch information
gits2501 authored Sep 28, 2017
1 parent b412aeb commit e5afb8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
language: node_js
node_js:
- '5.0'
- '4.8.4'
- '5.5.0'
- '5.12.0'
- '6.0.0'
- '8.6.0'
git:
depth: 3
15 changes: 9 additions & 6 deletions hmacSha1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ try{
crypto = require('crypto');

sha1 = function(key,enc, format){
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
enc = enc || 'binary'; // Fix for node versions >=6.0.0, in which default encoding is
// changed to utf-8.
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
}

}
Expand All @@ -28,9 +30,10 @@ 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

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;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "node ./test/test.js"
},
"engines": {"node": ">=0.1.92"},
"engines": {"node": "<6.0.0"},
"author": {
"name":"gits2501",
"email":"[email protected]",
Expand Down

0 comments on commit e5afb8c

Please sign in to comment.