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
gulp_assets-1.0.0.pre.5 template/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
gulp_assets-1.0.0.pre.4 template/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
gulp_assets-1.0.0.pre.3 template/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.268 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.267 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.266 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.265 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.264 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.263 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.262 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.261 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.260 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.259 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.258 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.256 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.255 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.254 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.253 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.252 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js
smock-0.1.251 node_modules/webpack/node_modules/node-libs-browser/node_modules/crypto-browserify/node_modules/sha.js/test/prepare/vectors.js