Open bgilbert opened 8 years ago
Whoa, this is really cool. I honestly had no idea this API even existed. I really would like to use this in place of Crypto.js wherever possible. In fact, it looks like this is available in all File API browsers, with the exception of IE10 (which has very low market share anyway and has been made redundant w/ IE11).
Are you able/willing to issue a pull request to cover this? I would certainly be willing to help you iron out any issue with your code and answer questions along the way.
I'd love to work on this, but it seems I'm not going to have the time. Thanks for asking, though!
It turns out that IE11 not only prefixes the API, but implements an older draft of the spec that uses event callbacks instead of Promises.
This is not surprising (and even expected) since IE11 doesn't support promises.
Type of issue [REQUIRED]
feature request
Uploader type [REQUIRED]
S3
Feature request details [DELETE EVERYTHING IN THIS SECTION IF THIS IS A BUG REPORT]
Detailed description of the feature
The Web Cryptography API provides native bindings to a number of crypto primitives, including hashing. If available, it should be able to compute payload hashes much more efficiently than pure JavaScript.
I tested SHA-256 performance with the existing code and with Web Crypto, by hashing a 5 MiB ArrayBuffer 200 times. Results on my machine (average of 3 runs):
Chrome only exposes the API to secure origins; other origins receive a rejected Promise if they try to use it. Safari exposes a prefixed API.
Proof-of-concept patch