There is no way to do this, because the Crypto class and methods are "native code", that is, they are implemented at a lower level in the browser, so we canβt extract the code and move it to another place. I tried using the Chrome Transferrable Objects . which is removed from the current context and passed to the employee, but this causes an error. I do not think that crypto-api should be associated with the DOM (WebWorkers will not touch the DOM, since it is not thread safe), but I have never implemented cryptography before. In Node, we have async api, so for me, at least, it looks like it should be thread safe.
http://cl.ly/image/0r0P3m3D2h07 <- Check window.crypto
http://cl.ly/image/0G1G0F1Y0d3Z <- Sample code for transferring cryptographic code to the WebWorker browser.
I created a WebWorker script to make sure that maybe itβs just possible that Chrome and Firefox had different implementations, and unfortunately I was wrong.
I sent an email to the authors of the W3C Web Crypto API Proposal , and you should as well. At the moment, the project has several open questions, so it seems that it can change. Having either an asynchronous API or a crypto API available in Web Workers seems perfectly reasonable to me. It seems to be bad to block the main event loop.
source share