Closed GoogleCodeExporter closed 9 years ago
To do that, I would probably extend WordArray to create a new TypedWordArray
type that we could customize. And I'd probably keep that definition in a
separate component file rather than in the core since it wouldn't be
cross-browser.
In fact, since JavaScript is loosely typed, you should be able to pass
WordArray a typed array, and it would just use it and continue on as normal.
You may run into problems, however, when the library tries to use the standard
array methods, such as push, slice and splice. Something to keep in mind if you
decide to toy with the idea.
Original comment by Jeff.Mott.OR
on 22 Aug 2012 at 10:00
Original comment by Jeff.Mott.OR
on 22 Aug 2012 at 10:00
Original comment by Jeff.Mott.OR
on 22 Aug 2012 at 10:01
Original comment by Jeff.Mott.OR
on 22 Aug 2012 at 10:02
I like the second idea of just having WordArray be able to accept an
ArrayBuffer. That seems like the most natural fit for users of the library.
However, my thinking was to actually extract the data out of the ArrayBuffer,
into the WordArray words member. Since this member is accessed directly in the
library, this seems like the only real option without significant surgery.
Doing the ArrayBuffer <-> WordArray.words conversions won't be particularly
fast, but they'll at least be convenient for users of the service.
Thoughts?
Original comment by brye...@chromium.org
on 23 Aug 2012 at 12:54
The latest release includes the ability to create WordArrays from typed arrays.
You'll need to include an additional component -- lib-typedarrays.
<script
src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/core.js"></sc
ript>
<script
src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/lib-typedarra
ys.js"></script>
<script>
var wordArray = CryptoJS.lib.WordArray.create(uint8View);
</script>
You can create a WordArray from any of the typed array views -- Int8Array,
Int16Array, etc. -- or from an ArrayBuffer, or from a DataView.
Original comment by Jeff.Mott.OR
on 7 Jan 2013 at 1:55
This is awesome! Thank you.
Original comment by brye...@chromium.org
on 7 Jan 2013 at 6:46
Original issue reported on code.google.com by
brye...@chromium.org
on 22 Aug 2012 at 9:18