package/package.json000644 001750 000144 0000001037 12604670113013014 0ustar00000000 000000 { "name": "shasum", "version": "1.0.2", "homepage": "https://github.com/dominictarr/shasum", "repository": { "type": "git", "url": "git://github.com/dominictarr/shasum.git" }, "dependencies": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" }, "devDependencies": {}, "browser": { "./index.js": "./browser.js" }, "scripts": { "test": "node test/index.js && node test/index.js browser" }, "author": "'Dominic Tarr' (http://dominictarr.com)", "license": "MIT" } package/.npmignore000644 001750 000144 0000000052 12343202310012507 0ustar00000000 000000 node_modules node_modules/* npm_debug.log package/README.md000644 001750 000144 0000000505 12454455660012017 0ustar00000000 000000 # shasum Single function that return the sha1sum. Installing this is just a little bit quicker than reading the crypto documentation. ``` js var shasum = require('shasum') shasum(string || buffer || object) ``` Oh yeah, it works in the browser too, with [browserify](https://npmjs.org/package/browserify) ## License MIT package/LICENSE000644 001750 000144 0000002061 12343202310011517 0ustar00000000 000000 Copyright (c) 2012 'Dominic Tarr' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/browser.js000644 001750 000144 0000000601 12454455660012556 0ustar00000000 000000 var createHash = require('sha.js') var Buffer = require('buffer').Buffer var stringify = require('json-stable-stringify') module.exports = function hash (str, alg, format) { str = 'string' === typeof str ? str : Buffer.isBuffer(str) ? str : stringify(str) return createHash(alg || 'sha1') .update(str, Buffer.isBuffer(str) ? null : 'utf8').digest(format || 'hex') } package/index.js000644 001750 000144 0000000615 12343202310012162 0ustar00000000 000000 var createHash = require('crypto').createHash var Buffer = require('buffer').Buffer var stringify = require('json-stable-stringify') module.exports = function hash (str, alg, format) { str = 'string' === typeof str ? str : Buffer.isBuffer(str) ? str : stringify(str) return createHash(alg || 'sha1') .update(str, Buffer.isBuffer(str) ? null : 'utf8').digest(format || 'hex') } package/.travis.yml000644 001750 000144 0000000053 12343202310012622 0ustar00000000 000000 language: node_js node_js: - 0.6 - 0.8 package/test/index.js000644 001750 000144 0000001537 12454455660013172 0ustar00000000 000000 var equal = require('assert').equal var hash = require(process.argv[2] === 'browser' ? '../browser.js' : '..') equal(hash('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d') equal(hash('abce'), '0a431a7631cabf6b11b984a943127b5e0aa9d687') equal(hash({}), 'bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f') equal(hash([]), '97d170e1550eee4afc0af065b78cda302a97674c') equal(hash(new Buffer('abc')), 'a9993e364706816aba3e25717850c26c9cd0d89d') equal(hash('ab\xff'),'ba5142a8207bd61baddf325088732e71cbfe8eb6') equal(hash(new Buffer('ab\xff').toString()), 'ba5142a8207bd61baddf325088732e71cbfe8eb6') equal(hash({a:1,b:2,c:3}), hash({c:3,b:2,a:1})) equal(hash({a:1,b:2,c:3}), hash({c:3,b:2,a:1})) equal(hash({a:1,b:[2,3],c:4}), hash({c:4,b:[2,3],a:1})) equal(hash({a:1,b:[2,{c:3,d:4}],e:5}), hash({e:5,b:[2,{d:4,c:3}],a:1}))