Sha256: 0277a1331cdb4d64ff71007dc38753875b3f0182ffc2b2aba5a83ab4ff0eebe7

Contents?: true

Size: 1.17 KB

Versions: 65

Compression:

Stored size: 1.17 KB

Contents

var assert = require('assert')
var crypto = require('crypto')
var fs   = require('fs')
var path = require('path')

var dir = path.join(__dirname, 'vectors')

var vectors = fs.readdirSync(dir)
  .sort()
  .filter(function (f) {
    return f.match(/\.dat$/)
  })
  .map(function (f) {
    return fs.readFileSync(path.join(dir, f))
  })

var hashes = {}

;['sha1', 'sha256', 'md5'].forEach(function (name) {
  hashes[name] =
    fs.readFileSync(path.join(dir, 'byte-hashes.' + name), 'ascii')
    .split(/\r?\n/)
})

var expected = []

for (var i = 0; i < vectors.length; i++) {
  var sha512 = crypto.createHash('sha512').update(new Buffer(vectors[i])).digest('hex')

  expected.push({
    input  : vectors[i].toString('base64'),
    sha1   : hashes.sha1[i],
    sha256 : hashes.sha256[i],
    sha512 : sha512
  })

  assert.equal(
    crypto.createHash('sha1').update(new Buffer(vectors[i])).digest('hex'),
    hashes.sha1[i])

  assert.equal(
    crypto.createHash('sha256').update(new Buffer(vectors[i])).digest('hex'),
    hashes.sha256[i])

  assert.equal(
    crypto.createHash('md5').update(new Buffer(vectors[i])).digest('hex'),
    hashes.md5[i])
}

console.log(JSON.stringify(expected, null, 2))

Version data entries

65 entries across 65 versions & 2 rubygems

Version Path
smock-0.1.231 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.230 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.229 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.228 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.227 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.226 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.225 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.224 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.9 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.223 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.222 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.221 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.220 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.219 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.218 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.217 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.216 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.215 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.214 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.213 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js