Skip to content

Commit cff0e3a

Browse files
committed
Fix typo in README.md
Add hashing algorithms to README.md Pass length of buffer to x11 and quark
1 parent ef31ae5 commit cff0e3a

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ So far this native Node.js addon can do the following hashing algos
2121
```javascript
2222
var multiHashing = require('multi-hashing');
2323

24-
var algorithms = ['quark', 'x11', 'scrypt', 'scryptn', 'scryptjane', 'keccak', 'bcrypt'];
24+
var algorithms = ['quark', 'x11', 'scrypt', 'scryptn', 'scryptjane', 'keccak', 'bcrypt', 'skein', 'blake'];
2525

26-
var data = new Buffer("hash me good bro");
26+
var data = new Buffer("7000000001e980924e4e1109230383e66d62945ff8e749903bea4336755c00000000000051928aff1b4d72416173a8c3948159a09a73ac3bb556aa6bfbcad1a85da7f4c1d13350531e24031b939b9e2b", "hex");
2727

2828
var hashedData = algorithms.map(function(algo){
2929
if (algo === 'scryptjane'){
@@ -33,7 +33,7 @@ var hashedData = algorithms.map(function(algo){
3333
return multiHashing[algo](data, nTime, yaCoinChainStartTime);
3434
}
3535
else{
36-
return return multiHashing[algo](data);
36+
return multiHashing[algo](data);
3737
}
3838
});
3939

@@ -42,7 +42,7 @@ console.log(hashedData);
4242
//<SlowBuffer 0b de 16 ef 2d 92 e4 35 65 c6 6c d8 92 d9 66 b4 3d 65 ..... >
4343

4444
//Another example...
45-
var hashedScryptData = multiHashing.scrypt(new Buffer(32));
45+
var hashedScryptData = multiHashing.scrypt(new Buffer(80));
4646

4747
```
4848

multihashing.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ Handle<Value> quark(const Arguments& args) {
7777

7878
char * input = Buffer::Data(target);
7979
char * output = new char[32];
80+
81+
unsigned int input_len = Buffer::Length(target);
8082

81-
quark_hash(input, output);
83+
quark_hash(input, output, input_len);
8284

8385
Buffer* buff = Buffer::New(output, 32);
8486
return scope.Close(buff->handle_);
@@ -98,7 +100,9 @@ Handle<Value> x11(const Arguments& args) {
98100
char * input = Buffer::Data(target);
99101
char * output = new char[32];
100102

101-
x11_hash(input, output);
103+
unsigned int input_len = Buffer::Length(target);
104+
105+
x11_hash(input, output, input_len);
102106

103107
Buffer* buff = Buffer::New(output, 32);
104108
return scope.Close(buff->handle_);
@@ -240,8 +244,9 @@ Handle<Value> skein(const Arguments& args) {
240244
return except("Argument should be a buffer object.");
241245

242246
char * input = Buffer::Data(target);
243-
unsigned int input_len = Buffer::Length(target);
244247
char * output = new char[32];
248+
249+
unsigned int input_len = Buffer::Length(target);
245250

246251
skein_hash(input, output, input_len);
247252

@@ -262,9 +267,10 @@ Handle<Value> groestl(const Arguments& args) {
262267
return except("Argument should be a buffer object.");
263268

264269
char * input = Buffer::Data(target);
265-
unsigned int input_len = Buffer::Length(target);
266270
char * output = new char[32];
267271

272+
unsigned int input_len = Buffer::Length(target);
273+
268274
groestl_hash(input, output, input_len);
269275

270276
Buffer* buff = Buffer::New(output, 32);
@@ -284,9 +290,10 @@ Handle<Value> blake(const Arguments& args) {
284290
return except("Argument should be a buffer object.");
285291

286292
char * input = Buffer::Data(target);
287-
unsigned int input_len = Buffer::Length(target);
288293
char * output = new char[32];
289294

295+
unsigned int input_len = Buffer::Length(target);
296+
290297
blake_hash(input, output, input_len);
291298

292299
Buffer* buff = Buffer::New(output, 32);

quark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ be32dec_vect(uint32_t *dst, const unsigned char *src, size_t len)
106106
dst[i] = be32dec(src + i * 4);
107107
}
108108

109-
void quark_hash(const char* input, char* output)
109+
void quark_hash(const char* input, char* output, unsigned int len)
110110
{
111111
sph_blake512_context ctx_blake;
112112
sph_bmw512_context ctx_bmw;
@@ -124,7 +124,7 @@ void quark_hash(const char* input, char* output)
124124

125125

126126
sph_blake512_init(&ctx_blake);
127-
sph_blake512 (&ctx_blake, input, 80);
127+
sph_blake512 (&ctx_blake, input, len);
128128
sph_blake512_close (&ctx_blake, hashA); //0
129129

130130

quark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef QUARK_H
22
#define QUARK_H
33

4-
void quark_hash(const char* input, char* output);
4+
void quark_hash(const char* input, char* output, unsigned int len);
55

66
#endif

x11.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "sha3/sph_echo.h"
1818

1919

20-
void x11_hash(const char* input, char* output)
20+
void x11_hash(const char* input, char* output, unsigned int len)
2121
{
2222
sph_blake512_context ctx_blake;
2323
sph_bmw512_context ctx_bmw;
@@ -36,7 +36,7 @@ void x11_hash(const char* input, char* output)
3636
uint32_t hashA[16], hashB[16];
3737

3838
sph_blake512_init(&ctx_blake);
39-
sph_blake512 (&ctx_blake, input, 80);
39+
sph_blake512 (&ctx_blake, input, len);
4040
sph_blake512_close (&ctx_blake, hashA);
4141

4242
sph_bmw512_init(&ctx_bmw);

x11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
extern "C" {
66
#endif
77

8-
void x11_hash(const char* input, char* output);
8+
void x11_hash(const char* input, char* output, unsigned int len);
99

1010
#ifdef __cplusplus
1111
}

0 commit comments

Comments
 (0)