Skip to content

isomorphic mechanism to generate hmac digest, using Crypto on node.js and crypto.subtle in the browser

Notifications You must be signed in to change notification settings

justinph/hmac-isomorphic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hmac-isomorphic

Usage

Make sure that whatever build system you are using (Webpack etc) is honoring the browser field in package.json. Then import the library.

The module provides a single function that returns a promise, both in node and in the browser. There are three arguments:

  1. algo, string: the signing algorithim to use. Can be sha256, sha512, etc. Be sure to use the naming mechanism from nodejs, e.g. sha256 not SHA-256.
  2. key, string: the encryption key to use. This should be secret.
  3. message, string: the message to generate the signature from.
const createHmacDigest = require('hmac-isomorphic');
createHmacDigest('sha256', 'abc123', 'def456').then(console.log);

Implementation

About

isomorphic mechanism to generate hmac digest, using Crypto on node.js and crypto.subtle in the browser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published