diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/sha.js/test | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/sha.js/test')
-rw-r--r-- | node_modules/sha.js/test/hash.js | 75 | ||||
-rw-r--r-- | node_modules/sha.js/test/test.js | 100 | ||||
-rw-r--r-- | node_modules/sha.js/test/vectors.js | 72 |
3 files changed, 0 insertions, 247 deletions
diff --git a/node_modules/sha.js/test/hash.js b/node_modules/sha.js/test/hash.js deleted file mode 100644 index 5fa000d..0000000 --- a/node_modules/sha.js/test/hash.js +++ /dev/null @@ -1,75 +0,0 @@ -var tape = require('tape') -var Hash = require('../hash') -var hex = '0A1B2C3D4E5F6G7H' - -function equal (t, a, b) { - t.equal(a.length, b.length) - t.equal(a.toString('hex'), b.toString('hex')) -} - -var hexBuf = Buffer.from('0A1B2C3D4E5F6G7H', 'utf8') -var count16 = { - strings: ['0A1B2C3D4E5F6G7H'], - buffers: [ - hexBuf, - Buffer.from('80000000000000000000000000000080', 'hex') - ] -} - -var empty = { - strings: [''], - buffers: [ - Buffer.from('80000000000000000000000000000000', 'hex') - ] -} - -var multi = { - strings: ['abcd', 'efhijk', 'lmnopq'], - buffers: [ - Buffer.from('abcdefhijklmnopq', 'ascii'), - Buffer.from('80000000000000000000000000000080', 'hex') - ] -} - -var long = { - strings: [hex + hex], - buffers: [ - hexBuf, - hexBuf, - Buffer.from('80000000000000000000000000000100', 'hex') - ] -} - -function makeTest (name, data) { - tape(name, function (t) { - var h = new Hash(16, 8) - var hash = Buffer.alloc(20) - var n = 2 - var expected = data.buffers.slice() - // t.plan(expected.length + 1) - - h._update = function (block) { - var e = expected.shift() - equal(t, block, e) - - if (n < 0) { - throw new Error('expecting only 2 calls to _update') - } - } - h._hash = function () { - return hash - } - - data.strings.forEach(function (string) { - h.update(string, 'ascii') - }) - - equal(t, h.digest(), hash) - t.end() - }) -} - -makeTest('Hash#update 1 in 1', count16) -makeTest('empty Hash#update', empty) -makeTest('Hash#update 1 in 3', multi) -makeTest('Hash#update 2 in 1', long) diff --git a/node_modules/sha.js/test/test.js b/node_modules/sha.js/test/test.js deleted file mode 100644 index dac8580..0000000 --- a/node_modules/sha.js/test/test.js +++ /dev/null @@ -1,100 +0,0 @@ -var crypto = require('crypto') -var tape = require('tape') -var Sha1 = require('../').sha1 - -var inputs = [ - ['', 'ascii'], - ['abc', 'ascii'], - ['123', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789abcdef', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789abc', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789ab', 'ascii'], - ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', 'ascii'], - ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'ascii'], - ['foobarbaz', 'ascii'] -] - -tape("hash is the same as node's crypto", function (t) { - inputs.forEach(function (v) { - var a = new Sha1().update(v[0], v[1]).digest('hex') - var e = crypto.createHash('sha1').update(v[0], v[1]).digest('hex') - console.log(a, '==', e) - t.equal(a, e) - }) - - t.end() -}) - -tape('call update multiple times', function (t) { - inputs.forEach(function (v) { - var hash = new Sha1() - var _hash = crypto.createHash('sha1') - - for (var i = 0; i < v[0].length; i = (i + 1) * 2) { - var s = v[0].substring(i, (i + 1) * 2) - hash.update(s, v[1]) - _hash.update(s, v[1]) - } - - var a = hash.digest('hex') - var e = _hash.digest('hex') - console.log(a, '==', e) - t.equal(a, e) - }) - t.end() -}) - -tape('call update twice', function (t) { - var _hash = crypto.createHash('sha1') - var hash = new Sha1() - - _hash.update('foo', 'ascii') - hash.update('foo', 'ascii') - - _hash.update('bar', 'ascii') - hash.update('bar', 'ascii') - - _hash.update('baz', 'ascii') - hash.update('baz', 'ascii') - - var a = hash.digest('hex') - var e = _hash.digest('hex') - - t.equal(a, e) - t.end() -}) - -tape('hex encoding', function (t) { - inputs.forEach(function (v) { - var hash = new Sha1() - var _hash = crypto.createHash('sha1') - - for (var i = 0; i < v[0].length; i = (i + 1) * 2) { - var s = v[0].substring(i, (i + 1) * 2) - hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex') - _hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex') - } - var a = hash.digest('hex') - var e = _hash.digest('hex') - - console.log(a, '==', e) - t.equal(a, e) - }) - - t.end() -}) - -tape('call digest for more than MAX_UINT32 bits of data', function (t) { - var _hash = crypto.createHash('sha1') - var hash = new Sha1() - var bigData = Buffer.alloc(0x1ffffffff / 8) - - hash.update(bigData) - _hash.update(bigData) - - var a = hash.digest('hex') - var e = _hash.digest('hex') - - t.equal(a, e) - t.end() -}) diff --git a/node_modules/sha.js/test/vectors.js b/node_modules/sha.js/test/vectors.js deleted file mode 100644 index 48a646e..0000000 --- a/node_modules/sha.js/test/vectors.js +++ /dev/null @@ -1,72 +0,0 @@ -var tape = require('tape') -var vectors = require('hash-test-vectors') -// var from = require('bops/typedarray/from') -var Buffer = require('safe-buffer').Buffer - -var createHash = require('../') - -function makeTest (alg, i, verbose) { - var v = vectors[i] - - tape(alg + ': NIST vector ' + i, function (t) { - if (verbose) { - console.log(v) - console.log('VECTOR', i) - console.log('INPUT', v.input) - console.log(Buffer.from(v.input, 'base64').toString('hex')) - } - - var buf = Buffer.from(v.input, 'base64') - t.equal(createHash(alg).update(buf).digest('hex'), v[alg]) - - i = ~~(buf.length / 2) - var buf1 = buf.slice(0, i) - var buf2 = buf.slice(i, buf.length) - - console.log(buf1.length, buf2.length, buf.length) - console.log(createHash(alg)._block.length) - - t.equal( - createHash(alg) - .update(buf1) - .update(buf2) - .digest('hex'), - v[alg] - ) - - var j, buf3 - - i = ~~(buf.length / 3) - j = ~~(buf.length * 2 / 3) - buf1 = buf.slice(0, i) - buf2 = buf.slice(i, j) - buf3 = buf.slice(j, buf.length) - - t.equal( - createHash(alg) - .update(buf1) - .update(buf2) - .update(buf3) - .digest('hex'), - v[alg] - ) - - setTimeout(function () { - // avoid "too much recursion" errors in tape in firefox - t.end() - }) - }) -} - -if (process.argv[2]) { - makeTest(process.argv[2], parseInt(process.argv[3], 10), true) -} else { - vectors.forEach(function (v, i) { - makeTest('sha', i) - makeTest('sha1', i) - makeTest('sha224', i) - makeTest('sha256', i) - makeTest('sha384', i) - makeTest('sha512', i) - }) -} |