1.0.1 • Published 9 years ago

stable-sha1 v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

stable-sha1

Get a consistent sha1 hash for a JSON object in both browser and node

Inspired by shasum, but unlike shasum it is only 3.6KB once minified and gzipped. It does this by only supporting shasums for objects, not for buffers. It also achieves further savings by assuming a browser with support for JSON and using the relatively lightweight rusha instead of the very large crypto-browserify.

Build Status Dependency Status NPM version

Installation

npm install stable-sha1

Usage

'use strict';

var assert = require('assert');
var sha = require('stable-sha1');

assert(sha({a: 1, b: 2, z: 3}) === sha({z: 3, b: 2, a: 1}));
assert(sha({a: 1, b: 2, z: 3}) !== sha({z: 3, b: 2, a: 2}));

Contributing

Be sure to run tests before submitting a pull request.

$ npm install
$ npm test
tests passed
$ npm run browser

Load http://localhost:3000 in your web browser and you should see "tests passed".

License

MIT