SHA-256 implementation in JavaScript with typed arrays that works in modern browsers and Node.js. Implements the hash function, HMAC, and PBKDF2.
Public domain. No warranty.
You can install fast-sha256-js via a package manager:
$ bower install fast-sha256
NPM:
$ npm install fast-sha256
Functions accept and return Uint8Array
s.
To convert strings, use external library (for example,
nacl.util).
Returns a SHA-256 hash of the message.
Returns an HMAC-SHA-256 of the message for the key.
Returns a key of length dkLen derived using PBKDF2-HMAC-SHA256 from the given password, salt, and the number of rounds.
Install development dependencies:
$ npm install
Run tests:
$ npm test
Run tests on different source file:
$ SHA256_SRC=sha256.min.js npm test
Run benchmark:
$ npm run bench
(or in a browser, open tests/bench.html
).
Build minified version:
$ npm run build
While this implementation is pretty fast compared to previous generation implementations, if you need a faster one, check out asmCrypto.