srijs / rusha

High-performance pure-javascript SHA1 implementation suitable for large binary data, reaching up to half the native speed.
https://npmjs.org/rusha
MIT License
277 stars 32 forks source link

Ordered bytes in rawDigest output #11

Closed mathbruyen closed 10 years ago

mathbruyen commented 10 years ago

Rusha#rawDigest used to return an Int32Array with the byte order of the underlying platform and not sliced, which made the usage of the underlying ArrayBuffer obtained by Int32Array#buffer hard (one had to copy in another array using the proper endianness).

Changes a bit the API as rawDigest now reportedly returns an ArrayBuffer instead of an Int32Array. This ArrayBuffer is sliced at 20 bytes.

Added tests using the string abc as an example (as for the spec).

If you are not happy with changing the API to returning ArrayBuffer, I can get back to returning an Int32Array but this time with an underlying buffer sliced and proper endianness. Same thing if you are not happy with Mocha tests, I can change that to whatever you prefer.

srijs commented 10 years ago

Hi there! Thanks for contributing! :) And yay for the Mocha tests ;)

Two issues:

mathbruyen commented 10 years ago

I'll update the proper file. What are the commands to generate the other ones?

I will go back to the Int32Array too.

srijs commented 10 years ago

Just a simple make rusha.min.js will do.

mathbruyen commented 10 years ago

Source file updated and it returns again an Int32Array.

My bad about the build script, I did not spot the Makefile. To remove any doubt, I added commands in README.md

srijs commented 10 years ago

Wow, man, you're awesome! :+1: And thanks for contributing!

srijs commented 10 years ago

Hey, I just moved the endianness fix out of RushaCore, into the rawDigest function, to restore asm.js functionality. The tests run fine for me. Could you check this is also the case for you?

mathbruyen commented 10 years ago

It is fine to me (I'm not that fluent in ams.js), thanks for merging!