Closed GoogleCodeExporter closed 9 years ago
It's interesting idea. The upcoming 3.0 release will indeed support
incrementally appending the message. Though, it'll be tricky to continue
appending after you've completed the digest. Completing the digest involves
adding padding, then hashing the last padded block.
Original comment by Jeff.Mott.OR
on 26 Jan 2012 at 7:23
Cool. It seems doable if you just make the final padding and hashing
calculation local to the function that returns the digest instead of mutating
the object (you could cache the digest if you were worried about the efficiency
of repeated calls to digest()).
Is the code for your upcoming 3.0 release currently available in a public
repository? If so I'd be happy to take a stab at it and send a patch, if you
like.
Original comment by haber...@google.com
on 26 Jan 2012 at 8:00
http://code.google.com/p/crypto-js/source/browse/branches/#branches%2F3.x%2Fsrc
Original comment by Jeff.Mott.OR
on 26 Jan 2012 at 8:08
I also have the need to compute MD5 checksums incrementally. This, combined
with the new HTML5 File APIs would allow for a very robust upload mechanism.
Any estimate on when this functionality (supposedly in version 3) will be
available?
Thanks!
Evan
Original comment by e...@dnanexus.com
on 16 Mar 2012 at 9:23
Version 3 is very close. I'd expect it to be ready within the next month. I'm
mostly focusing on the cipher components now, and the hashing components are
largely set.
Here's a preview for you.
<!doctype html>
<script
src="http://crypto-js.googlecode.com/svn-history/r437/branches/3.x/src/core.js">
</script>
<script
src="http://crypto-js.googlecode.com/svn-history/r437/branches/3.x/src/sha256.js
"></script>
<script
src="http://crypto-js.googlecode.com/svn-history/r437/branches/3.x/src/enc-base6
4.js"></script>
<script>
// Basic hashing
var hash = CryptoJS.SHA256('abc');
// Output encoding
alert('Hash encoded as latin-1 string: ' + hash.toString(CryptoJS.enc.Latin1));
alert('Hash encoded as base-64 string: ' + hash.toString(CryptoJS.enc.Base64));
alert('Hash encoded as hex string: ' + hash); // Default is hex
// Incremental hashing
var sha256 = CryptoJS.algo.SHA256.create();
sha256.update('a');
sha256.update('b');
sha256.update('c');
var hash = sha256.finalize();
alert('Incrementally computed hash: ' + hash);
// Incremental hashing, capturing intermediate hash values
var sha256 = CryptoJS.algo.SHA256.create();
var hashA = sha256.update('a').clone().finalize();
var hashAB = sha256.update('b').clone().finalize();
var hashABC = sha256.update('c').clone().finalize();
alert('Intermediate hash value "a": ' + hashA);
alert('Intermediate hash value "ab": ' + hashAB);
alert('Intermediate hash value "abc": ' + hashABC);
</script>
Original comment by Jeff.Mott.OR
on 16 Mar 2012 at 10:27
This feature now officially available with version 3.
Original comment by Jeff.Mott.OR
on 6 May 2012 at 7:51
Great! Thanks for the excellent work, Jeff.
Original comment by e...@dnanexus.com
on 7 May 2012 at 7:50
Original issue reported on code.google.com by
jhaber...@gmail.com
on 26 Jan 2012 at 6:10