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

You may want to take a look at the Stanford JS Crypto Library

GitHub

Website with Examples

From the website:

SJCL is secure. It uses the industry-standard AES algorithm at 128, 192 or 256 bits; the SHA256 hash function; the HMAC authentication code; the PBKDF2 password strengthener; and the CCM and OCB authenticated-encryption modes.

SJCL has a test page that shows how long it will take.

184 milliseconds for a SHA256 iterative. And 50 milliseconds for a SHA-256 from catameringue.

Test page

Sample code:

Encrypt data:
sjcl.encrypt("password", "data")

Decrypt data: sjcl.decrypt("password", "encrypted-data")

Leave a Comment