From bf565c3f494b84310df5e15ee66b523f7df28d23 Mon Sep 17 00:00:00 2001 From: Alex Wolfe Date: Thu, 20 Oct 2016 12:06:13 -0500 Subject: [PATCH] Resolve 'Invalid key length' error on Node 6 --- .travis.yml | 5 +++-- lib/multipass.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 12b2631..56c2d58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: node_js node_js: - - 0.8 - - 0.6 + - 4 + - 5 + - 6 diff --git a/lib/multipass.js b/lib/multipass.js index a96e973..d9edaba 100644 --- a/lib/multipass.js +++ b/lib/multipass.js @@ -8,7 +8,7 @@ var api = module.exports = function(apiKey, siteKey) { if (!(this instanceof api)) return new api(apiKey, siteKey); if (!(typeof apiKey == 'string' && apiKey.length > 0)) throw new Error('Invalid API key'); if (!(typeof siteKey == 'string' && siteKey.length > 0)) throw new Error('Invalid site key'); - this._key = crypto.createHash('sha1').update(apiKey + siteKey).digest('binary').substring(0, BLOCK_SIZE); + this._key = crypto.createHash('sha1').update(apiKey + siteKey).digest().slice(0, BLOCK_SIZE); this._iv = new Buffer('OpenSSL for Ruby', 'ascii'); return this; };