How to check integrity of loaded Javascript code

I am launching a bitcoin wallet that uses browser-side Javascript to encrypt and decrypt bitcoin keys.

I want to make javascript available for verification on Github, and then download javascript from the github repository.

My problem is that I need to check the integrity of the loaded Javascript to make sure it has not been tampered with on Github.

How can i do this? It would be something like.

  • Download Javascript using an ajax call.
  • MD5 hash and comparison.
  • If in good shape, do it.
+5
source share
1 answer

There is (or will be soon) an elegant way to achieve this now (2 years after the question was asked).

http://www.w3.org/TR/SRI/

"" script:

<script src="https://github.com/<path>/yourscript.js"
        integrity="sha256-SDf......">

script, AJAX. script, CDN ( github )

+4

All Articles