Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

adoankim/fast-sha256-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fast-sha256-js

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.

Build Status

Installation

You can install fast-sha256-js via a package manager:

Bower:

$ bower install fast-sha256

NPM:

$ npm install fast-sha256

or download source code.

Usage

Functions accept and return Uint8Arrays. To convert strings, use external library (for example, nacl.util).

sha256(message)

Returns a SHA-256 hash of the message.

sha256.hmac(key, message)

Returns an HMAC-SHA-256 of the message for the key.

sha256.pbkdf2(password, salt, rounds, dkLen)

Returns a key of length dkLen derived using PBKDF2-HMAC-SHA256 from the given password, salt, and the number of rounds.

Testing and building

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

Notes

While this implementation is pretty fast compared to previous generation implementations, if you need a faster one, check out asmCrypto.

About

SHA-256, HMAC and PBKDF2 implementation in JavaScript with typed arrays for modern browsers and Node.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.9%
  • Other 0.1%