title: Create SHA-256 hash from a Blob/File in javascript
body: <p>I need to create a SHA-256 digest from a file (~6MB) inside the browser. The only way that I've managed to do it so far was like this:</p>
  <pre><code>var reader = new FileReader();
  reader.onload = function() {
      // this gets rid of the mime-type data header
      var actual_contents = reader.result.slice(reader.result.indexOf(',') + 1);
      var what_i_need = new jsSHA(actual_contents, &quot;B64&quot;).getHash(&quot;SHA-256&quot;, &quot;HEX&quot;);
  }
  reader.readAsDataURL(some_file);
  </code></pre>
  <p>While this works correctly, the problem is that it's very slow. It took ~2-3 seconds for a 6MB file. How can I improve this?</p>