diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:10:37 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 15:11:17 +0200 |
commit | 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch) | |
tree | 70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/create-hash/test.js | |
parent | aca1143cb9eed16cf37f04e475e4257418dd18ac (diff) |
fix build issues and add typedoc
Diffstat (limited to 'node_modules/create-hash/test.js')
-rw-r--r-- | node_modules/create-hash/test.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/node_modules/create-hash/test.js b/node_modules/create-hash/test.js index 0c6bd88c3..3928d6640 100644 --- a/node_modules/create-hash/test.js +++ b/node_modules/create-hash/test.js @@ -1,8 +1,7 @@ -var fs = require('fs') var test = require('tape') var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160', 'ripemd160'] -var encodings = [/*'binary',*/ 'hex', 'base64']; +var encodings = ['hex', 'base64'] // ignore binary var vectors = require('hash-test-vectors') vectors.forEach(function (vector) { vector.ripemd160 = vector.rmd160 @@ -15,25 +14,27 @@ algorithms.forEach(function (algorithm) { var input = new Buffer(obj.input, 'base64') var node = obj[algorithm] var js = createHash(algorithm).update(input).digest('hex') - t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node) + t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node) }) encodings.forEach(function (encoding) { - vectors.forEach(function (obj, i) { - var input = new Buffer(obj.input, 'base64').toString(encoding) - var node = obj[algorithm] - var js = createHash(algorithm).update(input, encoding).digest('hex') - t.equal(js, node, algorithm + '(testVector['+i+'], '+encoding+') == ' + node) - }) - }); + vectors.forEach(function (obj, i) { + var input = new Buffer(obj.input, 'base64').toString(encoding) + var node = obj[algorithm] + var js = createHash(algorithm).update(input, encoding).digest('hex') + t.equal(js, node, algorithm + '(testVector[' + i + '], ' + encoding + ') == ' + node) + }) + }) + vectors.forEach(function (obj, i) { var input = new Buffer(obj.input, 'base64') var node = obj[algorithm] - var hash = createHash(algorithm); + var hash = createHash(algorithm) hash.end(input) var js = hash.read().toString('hex') - t.equal(js, node, algorithm + '(testVector['+i+']) == ' + node) + t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node) }) + t.end() }) -}); +}) |