npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hash-test-vectors

v1.3.2

Published

test vectors for hashes

Downloads

13,816

Readme

hash-test-vectors

The nist test vectors expanded to cover every hash function supported by node.js, output is saved in a json file, so that it is possible to run tests in the browser.

NIST provides test vectors for sha and md5, and this module takes that set and outputs a json file containing the input (in base 64) plus all output of every hash function that node.js supports.

This makes it easy to test javascript hash functions, with fairly roboust coverage.

I took the original test vectors at http://www.nsrl.nist.gov/testdata/

example

var vectors = require('hash-test-vectors')
var tape = require('tape')
var MySha1 = require('./my-sha1-implementation')

vectors.forEach(function (v, i) {

  tape('my-sha1 against test vector ' + i, function (t) {
    //test in bash64 encoding + as a buffer
    t.equal(new MySha1().update(v.input, 'base64').digest('hex'), v.sha1)
    t.equal(new MySha1().update(new Buffer(v.input, 'base64')).digest('hex'), v.sha1)
    t.end()
  })
})

hmac example

hmac vectors taken from rfc4231 (included in this repo)

each test vector has {key: hex, data: hex} and the outputs of hmac with every hash algorithm in node, also in hex encoding.

var vectors = require('hash-test-vectors')
var tape = require('tape')
var MySha1Hmac = require('./my-sha1-hmac-implementation')

vectors.forEach(function (v, i) {
  tape('my-sha1-hmac against test vector ' + i, function (t) {
    //test in bash64 encoding + as a buffer
    t.equal(new MySha1Hmac(new Buffer(v.key, 'hex')).update(v.data, 'hex').digest('hex'), v.sha1)
    t.end()
  })
})

pbkdf2 example

pbkdf2 vectors taken from rfc6070 (also included in this repo)

var vectors = require('hash-test-vectors')
var tape = require('tape')
var MyPbkdf2 = require('./my-pbkdf2-implementation')

vectors.forEach(function (v, i) {
  tape('my-pbkdf2 against test vector ' + i, function (t) {
    //test in bash64 encoding + as a buffer
    var key = new MyPbkdf2(v.password, v.salt, v.iterations, v.length)
    t.equal(key.toString('hex')), v.sha1)
    t.end()
  })
})

License

MIT