Create SHA-256 hash from a Blob/File in javascript

后端 未结 4 1854
不思量自难忘°
不思量自难忘° 2021-02-02 09:20

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:

var reader = new FileRead         


        
4条回答
  •  情书的邮戳
    2021-02-02 10:16

    It might be faster to use an emscripten compiled version of the crypto libraries,

    Q. How fast will the compiled code be?

    A. Emscripten's default code generation mode is in asm.js format, which is a subset of JavaScript designed to make it possible for JavaScript engines to execute very quickly. See here for up-to-date benchmark results. In many cases, asm.js can get quite close to native speed.

    You can find an Emscripten-compiled NaCl cryptographic library here.

提交回复
热议问题