Get a consistent sha1 hash for a JSON object in both browser and node
MIT License
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.
npm install stable-sha1
'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}));
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".
MIT