Open GoogleCodeExporter opened 8 years ago
I think it's reasonable to expect update() to accept typed arrays. I'll likely
change that. In the mean time, you'll have to do this:
md5.update( CryptoJS.lib.WordArray.create(typedArray) );
Original comment by Jeff.Mott.OR
on 22 Jan 2013 at 8:54
Thanks for the quick reply Jeff. Also that WordArray workaround will be
perfect! Is there also a workaround for Blob?
Thanks,
Evan
Original comment by e...@dnanexus.com
on 22 Jan 2013 at 9:17
Actually, I don't think this works. Please see the attached file for an example
using an ArrayBuffer. Can we change the issue type to bug? Is there any other
way I can accomplish this? I'm desperately in need of a way to incrementally
compute the MD5 checksum of a binary file in javascript. Thanks for your help!
Original comment by e...@dnanexus.com
on 22 Jan 2013 at 10:24
Attachments:
Ahh. I didn't document this very well... or, at all, for that matter... but
typed array support comes in a separate component. So include...
<script src='md5-3.1.2.min.js'></script>
<script src='http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/lib-typedarrays-min.js'></script>
...then everything should just work.
Original comment by Jeff.Mott.OR
on 22 Jan 2013 at 11:24
Ah, pefect! Thank you!
Original comment by e...@dnanexus.com
on 22 Jan 2013 at 11:36
Is this also working with SHA1? I am trying to compute the SHA1 hash of an
entire MP3 file in the browser, and I am getting hashes that do not match what
I expect even after trying: CryptoJS.lib.WordArray.create
This file is loaded via a FileReader calling readAsBinaryString
Original comment by wolfgang...@gmail.com
on 23 Jan 2013 at 5:38
Ah, I used readAsArrayBuffer instead and this method seems to be working now.
Is it difficult to handle "BinaryString"s ?
Original comment by wolfgang...@gmail.com
on 23 Jan 2013 at 5:48
[deleted comment]
Wolfgang, I'd suggest you stick with readAsArrayBuffer.
FileReader.readAsBinaryString has been deprecated -
https://developer.mozilla.org/en-US/docs/DOM/FileReaderSync#readAsBinaryString()
_Deprecated.
Original comment by e...@dnanexus.com
on 23 Jan 2013 at 5:50
Yeah, I liked the ArrayBuffer initially and realized it wasn't easily supported
by crypto-js until I found this issue.
I guess it isn't deprecated for the FileReader itself? But I don't mind using
ArrayBuffers :-)
Original comment by wolfgang...@gmail.com
on 23 Jan 2013 at 5:53
Indeed Jeff saved me when he showed me how to use ArrayBuffer. Also I do think
readAsBinaryString has been removed from the spec, see
http://www.w3.org/TR/FileAPI/, you won't find any mention of it.
Best,
Evan
Original comment by e...@dnanexus.com
on 23 Jan 2013 at 5:57
Very good point with a good canonical link :-) I'm new to Javascript and just
playing around (mostly), but these APIs are a little insane (input from
multiple parties, things deprecated all over).
Original comment by wolfgang...@gmail.com
on 23 Jan 2013 at 6:10
Just for the record, I recently found an pretty old post on the Google Group
with a snippet for building an ArrayBuffer (UInt8Array) from a WordArray.
Here's the link:
https://groups.google.com/d/msg/crypto-js/TOb92tcJlU0/Eq7VZ5tpi-QJ
IMO, that would be an awesome addition to CryptoJS to have a full ArrayBuffer
<-> ArrayBuffer flow.
Best
Original comment by xcam...@gmail.com
on 10 Oct 2013 at 10:10
Converting the typedArray to string/word array is nice to get things working,
but it's really slow.
Is it possible to implement the algorithms directly from the typedArray?
Original comment by shach...@gmail.com
on 18 Jun 2014 at 11:25
Original issue reported on code.google.com by
e...@dnanexus.com
on 22 Jan 2013 at 8:50