stable-sha1

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i stable-sha1

Weekly Downloads

15

Version

1.0.1

License

MIT

Last publish

Collaborators

  • forbeslindesay