Skip to content

Commit 10c18d9

Browse files
author
lms
committed
add createHash() support for rmd160
1 parent 18f22bb commit 10c18d9

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

create-hash.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var createHash = require('sha.js')
22

33
var md5 = toConstructor(require('./md5'))
4+
var rmd160 = toConstructor(require('ripemd160'))
45

56
function toConstructor (fn) {
67
return function () {
@@ -24,5 +25,6 @@ function toConstructor (fn) {
2425

2526
module.exports = function (alg) {
2627
if('md5' === alg) return new md5()
28+
if('rmd160' === alg) return new rmd160()
2729
return createHash(alg)
2830
}

md5.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010
var helpers = require('./helpers');
1111

12-
/*
13-
* Perform a simple self-test to see if the VM is working
14-
*/
15-
function md5_vm_test()
16-
{
17-
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
18-
}
19-
2012
/*
2113
* Calculate the MD5 of an array of little-endian words, and a bit length
2214
*/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"node": "*"
1616
},
1717
"dependencies": {
18+
"ripemd160": "0.2.0",
1819
"sha.js": "2.1.3"
1920
},
2021
"devDependencies": {

readme.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ in pure javascript so that it can run in the browser.
1111

1212
Here is the subset that is currently implemented:
1313

14-
* createHash (sha1, sha256, md5)
14+
* createHash (sha1, sha256, md5, rmd160)
1515
* createHmac (sha1, sha256, md5)
1616
* pbkdf2
1717
* pbkdf2Sync
@@ -29,8 +29,8 @@ The highest priority unimplemented features are
2929

3030
## contributions
3131

32-
If you are interested in writing a feature, please create implement as a new module,
33-
which will be incorperated into crypto-browserify as a dependency.
32+
If you are interested in writing a feature, please implement as a new module,
33+
which will be incorporated into crypto-browserify as a dependency.
3434

3535
All deps must be compatible with node's crypto
3636
(generate example inputs and outputs with node,

test/create-hash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var assertSame = require('./util').same
22
var fs = require('fs')
33
var test = require('tape')
44

5-
var algorithms = ['sha1', 'sha256', 'md5'];
5+
var algorithms = ['sha1', 'sha256', 'md5', 'rmd160'];
66
var encodings = [/*'binary',*/ 'hex', 'base64'];
77

88

0 commit comments

Comments
 (0)