Skip to content

Commit 69c84c5

Browse files
committed
update dependencies
md5.js extracted to crypto-browserify/md5.js ripemd160 updated for supporting streams in own repository sha.js updated for using hash-base instead cipher-base
1 parent 0c6bf84 commit 69c84c5

File tree

9 files changed

+116
-319
lines changed

9 files changed

+116
-319
lines changed

.travis.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
sudo: false
2+
os:
3+
- linux
24
language: node_js
3-
before_install:
4-
- "npm install npm -g"
55
node_js:
66
- "0.10"
7+
- "0.11"
78
- "0.12"
8-
- "4.0.0"
9+
- "4"
10+
- "5"
911
env:
10-
- TEST_SUITE=standard
11-
- TEST_SUITE=unit
12-
script: "npm run-script $TEST_SUITE"
13-
12+
matrix:
13+
- TEST_SUITE=unit
14+
matrix:
15+
include:
16+
- node_js: "4"
17+
env: TEST_SUITE=lint
18+
script: npm run $TEST_SUITE

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# create-hash
2+
3+
[![NPM Package](https://img.shields.io/npm/v/create-hash.svg?style=flat-square)](https://www.npmjs.org/package/create-hash)
4+
[![Build Status](https://img.shields.io/travis/crypto-browserify/createHash.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/createHash)
5+
[![Dependency status](https://img.shields.io/david/crypto-browserify/createHash.svg?style=flat-square)](https://david-dm.org/crypto-browserify/createHash#info=dependencies)
6+
7+
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
8+
9+
Node style [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) on pure JavaScript.
10+
11+
```js
12+
var createHash = require('create-hash')
13+
var hash = createHash('sha224')
14+
hash.update('synchronous write') // optional encoding parameter
15+
hash.digest() // synchronously get result with optional encoding parameter
16+
17+
hash.write('write to it as a stream')
18+
hash.end() // remember it's a stream
19+
hash.read() // only if you ended it as a stream though
20+
```
21+
22+
To get the JavaScript version even in node do `require('create-hash/browser')`
23+
24+
## License
25+
26+
MIT

browser.js

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,17 @@
11
'use strict'
2-
var inherits = require('inherits')
3-
var md5 = require('./md5')
4-
var rmd160 = require('ripemd160')
5-
var sha = require('sha.js')
6-
7-
var Base = require('cipher-base')
8-
9-
function HashNoConstructor (hash) {
10-
Base.call(this, 'digest')
11-
12-
this._hash = hash
13-
this.buffers = []
14-
}
15-
16-
inherits(HashNoConstructor, Base)
17-
18-
HashNoConstructor.prototype._update = function (data) {
19-
this.buffers.push(data)
20-
}
21-
22-
HashNoConstructor.prototype._final = function () {
23-
var buf = Buffer.concat(this.buffers)
24-
var r = this._hash(buf)
25-
this.buffers = null
26-
27-
return r
28-
}
29-
30-
function Hash (hash) {
31-
Base.call(this, 'digest')
32-
33-
this._hash = hash
34-
}
35-
36-
inherits(Hash, Base)
37-
38-
Hash.prototype._update = function (data) {
39-
this._hash.update(data)
40-
}
41-
42-
Hash.prototype._final = function () {
43-
return this._hash.digest()
44-
}
2+
var MD5 = require('md5.js')
3+
var RIPEMD160 = require('ripemd160')
4+
var shajs = require('sha.js')
455

466
module.exports = function createHash (alg) {
47-
alg = alg.toLowerCase()
48-
if (alg === 'md5') return new HashNoConstructor(md5)
49-
if (alg === 'rmd160' || alg === 'ripemd160') return new HashNoConstructor(rmd160)
50-
51-
return new Hash(sha(alg))
7+
alg = alg.toUpperCase()
8+
switch (alg) {
9+
case 'MD5':
10+
return new MD5()
11+
case 'RIPEMD160':
12+
case 'RMD160':
13+
return new RIPEMD160()
14+
default:
15+
return shajs(alg)
16+
}
5217
}

make-hash.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

md5.js

Lines changed: 0 additions & 151 deletions
This file was deleted.

package.json

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,47 @@
22
"name": "create-hash",
33
"version": "1.1.2",
44
"description": "create hashes for browserify",
5-
"browser": "browser.js",
6-
"main": "index.js",
7-
"scripts": {
8-
"standard": "standard",
9-
"test": "npm run-script standard && npm run-script unit",
10-
"unit": "node test.js | tspec"
11-
},
12-
"repository": {
13-
"type": "git",
14-
"url": "[email protected]:crypto-browserify/createHash.git"
15-
},
165
"keywords": [
17-
"crypto"
6+
"crypto",
7+
"hash",
8+
"md5",
9+
"ripemd160",
10+
"rpm160",
11+
"sha",
12+
"sha1",
13+
"sha224",
14+
"sha256",
15+
"sha384",
16+
"sha512"
1817
],
19-
"author": "",
20-
"license": "MIT",
18+
"homepage": "https://github.com/crypto-browserify/createHash",
2119
"bugs": {
2220
"url": "https://github.com/crypto-browserify/createHash/issues"
2321
},
24-
"homepage": "https://github.com/crypto-browserify/createHash",
22+
"license": "MIT",
23+
"files": [
24+
"browser.js",
25+
"index.js"
26+
],
27+
"main": "index.js",
28+
"repository": {
29+
"type": "git",
30+
"url": "https://github.com/crypto-browserify/createHash.git"
31+
},
32+
"scripts": {
33+
"lint": "standard",
34+
"test": "npm run lint && npm run unit",
35+
"unit": "tape test/*.js"
36+
},
37+
"dependencies": {
38+
"md5.js": "^1.3.4",
39+
"ripemd160": "^2.0.0",
40+
"sha.js": "^3.0.0"
41+
},
2542
"devDependencies": {
2643
"hash-test-vectors": "^1.3.2",
27-
"standard": "^5.3.1",
28-
"tap-spec": "^2.1.2",
29-
"tape": "^3.0.3"
44+
"standard": "^6.0.8",
45+
"tape": "^4.5.1"
3046
},
31-
"dependencies": {
32-
"cipher-base": "^1.0.1",
33-
"inherits": "^2.0.1",
34-
"ripemd160": "^1.0.0",
35-
"sha.js": "^2.4.0"
36-
}
47+
"browser": "browser.js"
3748
}

readme.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)