[Pkg-javascript-commits] [node-shasum] 01/23: initial
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:06:23 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-shasum.
commit c468fae3ef3381af3f99dddcd4a50ab025974d88
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Tue Oct 30 16:50:07 2012 +0100
initial
---
.gitignore | 3 +++
.travis.yml | 4 ++++
LICENSE | 22 ++++++++++++++++++++++
README.md | 16 ++++++++++++++++
index.js | 10 ++++++++++
package.json | 18 ++++++++++++++++++
test/index.js | 12 ++++++++++++
7 files changed, 85 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..13abef4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+node_modules/*
+npm_debug.log
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..895dbd3
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6d03581
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e1b21cc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
+# sha1sum
+
+Single function that return the sha1sum.
+Installing this is just a little bit quicker than reading the crypto documentation.
+
+``` js
+var sha1sum = require('sha1sum')
+sha1sum(string || buffer || object)
+```
+
+Oh yeah, it works in the browser too, with
+[crypto-browserify](https://npmjs.org/package/crypto-browserify)
+
+## License
+
+MIT
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..43b5412
--- /dev/null
+++ b/index.js
@@ -0,0 +1,10 @@
+
+var createHash = require('crypto').createHash
+var buffer = require('buffer').Buffer
+module.exports = function hash (str, alg, format) {
+ str = 'string' === typeof str ? str
+ : Buffer.isBuffer(str) ? str
+ : JSON.stringify(str)
+ return createHash(alg || 'sha1').update(str).digest(format || 'hex')
+}
+
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e14d1a2
--- /dev/null
+++ b/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "sha1sum",
+ "version": "0.0.0",
+ "homepage": "https://github.com/dominictarr/sha1sum",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/dominictarr/sha1sum.git"
+ },
+ "dependencies": {
+ },
+ "devDependencies": {
+ },
+ "scripts": {
+ "test": "set -e; for t in test/*.js; do node $t; done"
+ },
+ "author": "'Dominic Tarr' <dominic.tarr at gmail.com> (http://dominictarr.com)",
+ "license": "MIT"
+}
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..7077324
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,12 @@
+var equal = require('assert').equal
+var hash = require('..')
+
+
+equal(hash('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d')
+equal(hash('abce'), '0a431a7631cabf6b11b984a943127b5e0aa9d687')
+equal(hash({}), 'bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f')
+equal(hash([]), '97d170e1550eee4afc0af065b78cda302a97674c')
+equal(hash(new Buffer('abc')),
+ 'a9993e364706816aba3e25717850c26c9cd0d89d')
+
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shasum.git
More information about the Pkg-javascript-commits
mailing list