JSPM

  • Created
  • Published
  • Downloads 25923
  • Score
    100M100P100Q141489F
  • License MIT

Universal Module for Hash Function in JavaScript

Package Exports

  • js-crypto-hash
  • js-crypto-hash/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-crypto-hash) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Universal Module for Hash Function in JavaScript

CircleCI

WARNING: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.

Introduction and Overview

This library is designed to be 'universal' as a hash function module, i.e., it works both on most browsers and on Node.js just by importing from npm/source code. Note that in the design principle, the library fully utilizes native APIs like WebCrypto API to accelerate its operation if available.

Installation

At your project directory, do either one of the following.

  • From npm/yarn:
    $ npm install --save js-crypto-hash // npm
    $ yarn add js-crypto-hash // yarn
  • From GitHub:
    $ git clone https://github.com/junkurihara/js-crypto-hash.git

Then you should import the package as follows.

import hash from 'js-crypto-hash'; // for npm
import hash from 'js-crypto-hash/dist/index.js'; // for github

Usage

Compute hash value

const msg = ...; // Uint8Array of arbitrary length  
const hash = 'SHA-256';
hmac.compute(msg, hash).then( (digest) => {
  // now you get a hash of msg in Uint8Array
});

License

Licensed under the MIT license, see LICENSE file.