summaryrefslogtreecommitdiffstats
path: root/node_modules/create-hash
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/create-hash')
-rw-r--r--node_modules/create-hash/.travis.yml17
-rw-r--r--node_modules/create-hash/LICENSE21
-rw-r--r--node_modules/create-hash/README.md19
-rw-r--r--node_modules/create-hash/browser.js30
-rw-r--r--node_modules/create-hash/index.js1
-rw-r--r--node_modules/create-hash/md5.js5
-rw-r--r--node_modules/create-hash/package.json69
-rw-r--r--node_modules/create-hash/test.js41
8 files changed, 203 insertions, 0 deletions
diff --git a/node_modules/create-hash/.travis.yml b/node_modules/create-hash/.travis.yml
new file mode 100644
index 0000000..da59431
--- /dev/null
+++ b/node_modules/create-hash/.travis.yml
@@ -0,0 +1,17 @@
+sudo: false
+language: node_js
+before_install:
+ - "npm install npm -g"
+node_js:
+ - "4"
+ - "5"
+ - "6"
+ - "7"
+env:
+ matrix:
+ - TEST_SUITE=unit
+matrix:
+ include:
+ - node_js: "7"
+ env: TEST_SUITE=standard
+script: npm run $TEST_SUITE
diff --git a/node_modules/create-hash/LICENSE b/node_modules/create-hash/LICENSE
new file mode 100644
index 0000000..f06007a
--- /dev/null
+++ b/node_modules/create-hash/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 crypto-browserify contributors
+
+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/node_modules/create-hash/README.md b/node_modules/create-hash/README.md
new file mode 100644
index 0000000..bad028d
--- /dev/null
+++ b/node_modules/create-hash/README.md
@@ -0,0 +1,19 @@
+# create-hash
+
+[![Build Status](https://travis-ci.org/crypto-browserify/createHash.svg)](https://travis-ci.org/crypto-browserify/createHash)
+
+Node style hashes for use in the browser, with native hash functions in node.
+
+API is the same as hashes in node:
+```js
+var createHash = require('create-hash')
+var hash = createHash('sha224')
+hash.update('synchronous write') // optional encoding parameter
+hash.digest() // synchronously get result with optional encoding parameter
+
+hash.write('write to it as a stream')
+hash.end() // remember it's a stream
+hash.read() // only if you ended it as a stream though
+```
+
+To get the JavaScript version even in node do `require('create-hash/browser')`
diff --git a/node_modules/create-hash/browser.js b/node_modules/create-hash/browser.js
new file mode 100644
index 0000000..01841bb
--- /dev/null
+++ b/node_modules/create-hash/browser.js
@@ -0,0 +1,30 @@
+'use strict'
+var inherits = require('inherits')
+var MD5 = require('md5.js')
+var RIPEMD160 = require('ripemd160')
+var sha = require('sha.js')
+var Base = require('cipher-base')
+
+function Hash (hash) {
+ Base.call(this, 'digest')
+
+ this._hash = hash
+}
+
+inherits(Hash, Base)
+
+Hash.prototype._update = function (data) {
+ this._hash.update(data)
+}
+
+Hash.prototype._final = function () {
+ return this._hash.digest()
+}
+
+module.exports = function createHash (alg) {
+ alg = alg.toLowerCase()
+ if (alg === 'md5') return new MD5()
+ if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
+
+ return new Hash(sha(alg))
+}
diff --git a/node_modules/create-hash/index.js b/node_modules/create-hash/index.js
new file mode 100644
index 0000000..658f6a0
--- /dev/null
+++ b/node_modules/create-hash/index.js
@@ -0,0 +1 @@
+module.exports = require('crypto').createHash
diff --git a/node_modules/create-hash/md5.js b/node_modules/create-hash/md5.js
new file mode 100644
index 0000000..3643ee2
--- /dev/null
+++ b/node_modules/create-hash/md5.js
@@ -0,0 +1,5 @@
+var MD5 = require('md5.js')
+
+module.exports = function (buffer) {
+ return new MD5().update(buffer).digest()
+}
diff --git a/node_modules/create-hash/package.json b/node_modules/create-hash/package.json
new file mode 100644
index 0000000..c6a9e25
--- /dev/null
+++ b/node_modules/create-hash/package.json
@@ -0,0 +1,69 @@
+{
+ "_from": "create-hash@^1.1.0",
+ "_id": "create-hash@1.2.0",
+ "_inBundle": false,
+ "_integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
+ "_location": "/create-hash",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "create-hash@^1.1.0",
+ "name": "create-hash",
+ "escapedName": "create-hash",
+ "rawSpec": "^1.1.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.1.0"
+ },
+ "_requiredBy": [
+ "/browserify-aes",
+ "/browserify-sign",
+ "/create-hmac",
+ "/crypto-browserify",
+ "/pbkdf2",
+ "/public-encrypt"
+ ],
+ "_resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
+ "_shasum": "889078af11a63756bcfb59bd221996be3a9ef196",
+ "_spec": "create-hash@^1.1.0",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/crypto-browserify",
+ "author": "",
+ "browser": "browser.js",
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/createHash/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "cipher-base": "^1.0.1",
+ "inherits": "^2.0.1",
+ "md5.js": "^1.3.4",
+ "ripemd160": "^2.0.1",
+ "sha.js": "^2.4.0"
+ },
+ "deprecated": false,
+ "description": "create hashes for browserify",
+ "devDependencies": {
+ "hash-test-vectors": "^1.3.2",
+ "safe-buffer": "^5.0.1",
+ "standard": "^10.0.2",
+ "tap-spec": "^2.1.2",
+ "tape": "^4.6.3"
+ },
+ "homepage": "https://github.com/crypto-browserify/createHash",
+ "keywords": [
+ "crypto"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "create-hash",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/crypto-browserify/createHash.git"
+ },
+ "scripts": {
+ "standard": "standard",
+ "test": "npm run-script standard && npm run-script unit",
+ "unit": "node test.js | tspec"
+ },
+ "version": "1.2.0"
+}
diff --git a/node_modules/create-hash/test.js b/node_modules/create-hash/test.js
new file mode 100644
index 0000000..7c98f9f
--- /dev/null
+++ b/node_modules/create-hash/test.js
@@ -0,0 +1,41 @@
+var test = require('tape')
+
+var Buffer = require('safe-buffer').Buffer
+var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160', 'ripemd160']
+var encodings = ['hex', 'base64'] // ignore binary
+var vectors = require('hash-test-vectors')
+vectors.forEach(function (vector) {
+ vector.ripemd160 = vector.rmd160
+})
+var createHash = require('./browser')
+
+algorithms.forEach(function (algorithm) {
+ test('test ' + algorithm + ' against test vectors', function (t) {
+ vectors.forEach(function (obj, i) {
+ var input = Buffer.from(obj.input, 'base64')
+ var node = obj[algorithm]
+ var js = createHash(algorithm).update(input).digest('hex')
+ t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node)
+ })
+
+ encodings.forEach(function (encoding) {
+ vectors.forEach(function (obj, i) {
+ var input = Buffer.from(obj.input, 'base64').toString(encoding)
+ var node = obj[algorithm]
+ var js = createHash(algorithm).update(input, encoding).digest('hex')
+ t.equal(js, node, algorithm + '(testVector[' + i + '], ' + encoding + ') == ' + node)
+ })
+ })
+
+ vectors.forEach(function (obj, i) {
+ var input = Buffer.from(obj.input, 'base64')
+ var node = obj[algorithm]
+ var hash = createHash(algorithm)
+ hash.end(input)
+ var js = hash.read().toString('hex')
+ t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node)
+ })
+
+ t.end()
+ })
+})