Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fanatid committed Apr 18, 2016
1 parent 0c6bf84 commit 69c84c5
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 319 deletions.
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
sudo: false
os:
- linux
language: node_js
before_install:
- "npm install npm -g"
node_js:
- "0.10"
- "0.11"
- "0.12"
- "4.0.0"
- "4"
- "5"
env:
- TEST_SUITE=standard
- TEST_SUITE=unit
script: "npm run-script $TEST_SUITE"

matrix:
- TEST_SUITE=unit
matrix:
include:
- node_js: "4"
env: TEST_SUITE=lint
script: npm run $TEST_SUITE
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# create-hash

[![NPM Package](https://img.shields.io/npm/v/create-hash.svg?style=flat-square)](https://www.npmjs.org/package/create-hash)
[![Build Status](https://img.shields.io/travis/crypto-browserify/createHash.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/createHash)
[![Dependency status](https://img.shields.io/david/crypto-browserify/createHash.svg?style=flat-square)](https://david-dm.org/crypto-browserify/createHash#info=dependencies)

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

Node style [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) on pure JavaScript.

```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')`

## License

MIT
61 changes: 13 additions & 48 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,17 @@
'use strict'
var inherits = require('inherits')
var md5 = require('./md5')
var rmd160 = require('ripemd160')
var sha = require('sha.js')

var Base = require('cipher-base')

function HashNoConstructor (hash) {
Base.call(this, 'digest')

this._hash = hash
this.buffers = []
}

inherits(HashNoConstructor, Base)

HashNoConstructor.prototype._update = function (data) {
this.buffers.push(data)
}

HashNoConstructor.prototype._final = function () {
var buf = Buffer.concat(this.buffers)
var r = this._hash(buf)
this.buffers = null

return r
}

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()
}
var MD5 = require('md5.js')
var RIPEMD160 = require('ripemd160')
var shajs = require('sha.js')

module.exports = function createHash (alg) {
alg = alg.toLowerCase()
if (alg === 'md5') return new HashNoConstructor(md5)
if (alg === 'rmd160' || alg === 'ripemd160') return new HashNoConstructor(rmd160)

return new Hash(sha(alg))
alg = alg.toUpperCase()
switch (alg) {
case 'MD5':
return new MD5()
case 'RIPEMD160':
case 'RMD160':
return new RIPEMD160()
default:
return shajs(alg)
}
}
30 changes: 0 additions & 30 deletions make-hash.js

This file was deleted.

151 changes: 0 additions & 151 deletions md5.js

This file was deleted.

59 changes: 35 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,47 @@
"name": "create-hash",
"version": "1.1.2",
"description": "create hashes for browserify",
"browser": "browser.js",
"main": "index.js",
"scripts": {
"standard": "standard",
"test": "npm run-script standard && npm run-script unit",
"unit": "node test.js | tspec"
},
"repository": {
"type": "git",
"url": "[email protected]:crypto-browserify/createHash.git"
},
"keywords": [
"crypto"
"crypto",
"hash",
"md5",
"ripemd160",
"rpm160",
"sha",
"sha1",
"sha224",
"sha256",
"sha384",
"sha512"
],
"author": "",
"license": "MIT",
"homepage": "https://github.com/crypto-browserify/createHash",
"bugs": {
"url": "https://github.com/crypto-browserify/createHash/issues"
},
"homepage": "https://github.com/crypto-browserify/createHash",
"license": "MIT",
"files": [
"browser.js",
"index.js"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/crypto-browserify/createHash.git"
},
"scripts": {
"lint": "standard",
"test": "npm run lint && npm run unit",
"unit": "tape test/*.js"
},
"dependencies": {
"md5.js": "^1.3.4",
"ripemd160": "^2.0.0",
"sha.js": "^3.0.0"
},
"devDependencies": {
"hash-test-vectors": "^1.3.2",
"standard": "^5.3.1",
"tap-spec": "^2.1.2",
"tape": "^3.0.3"
"standard": "^6.0.8",
"tape": "^4.5.1"
},
"dependencies": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
"ripemd160": "^1.0.0",
"sha.js": "^2.4.0"
}
"browser": "browser.js"
}
19 changes: 0 additions & 19 deletions readme.md

This file was deleted.

Loading

0 comments on commit 69c84c5

Please sign in to comment.