Skip to content

Commit

Permalink
Proper block XORing
Browse files Browse the repository at this point in the history
  • Loading branch information
rlindsgaard committed Oct 24, 2015
1 parent eb708db commit dd28b17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cubehash.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@
data += String.fromCharCode(0)
}

for (i = 0; i < data.length; i += 1) {
state[0] ^= data.charCodeAt(i);
transform(state);
for (var i = 0; i < data.length; i += 32) {
var block = data.substr(i, 32);
for (var j = 0; j < 32; j++) {
state[j] ^= block.charCodeAt(j);
transform(state);
}
}

// finalize
Expand Down
4 changes: 2 additions & 2 deletions test/cubehash-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ describe('cubehash', function () {
);
assert.equal(
cubehash('Hello'),
'7e1bc1f5f6b2560f65318f6a6ed588b949a3c595319face48240f1b63942cbe3'
'83552374d8ae5023be5129802f9761a6f593afefb9fd42364159fe14c86153a2'
);
assert.equal(
cubehash('The quick brown fox jumps over the lazy dog'),
'35313466942166a44a412532e078287f5863ecc0041d139d42ac4240a9893451'
'49a6237974e4cc52355099bdc4d2e3c96c21e65b15c2247900dfcf52ed7f0124'
);
done();
});
Expand Down

0 comments on commit dd28b17

Please sign in to comment.