Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

universal-hmac-sha256-js

pur3miish145MIT3.0.2

A universal JavaScript HMAC-SHA256 hashing algorithm (browsers + Node.js).

blockchain, hash, sha256, hmac, cryptography, mac, javascript, universal, isomorphic, browser, based, node

readme

Universal-HMAC-SHA256-js

An optimised universal JavaScript (Browsers + Node.js) HMAC-SHA256 hashing algorithm.

  • Zero dependencies
  • 🤏 Small bundle impact (~400 bytes)

Setup

npm i universal-hmac-sha256-js

Node CJS.

const hmac_sha256 = import('universal-hmac-sha256-js/hmac-sha256-node.mjs')

Node ESM.

import hmac_sha256 from 'universal-hmac-sha256-js/hmac-sha256-node.mjs'

Deno.

import hmac_sha256 from 'https://deno.land/x/hmacsha256/hmac-sha256-deno.mjs'

API

function hmac_sha256

Performs a HMAC SHA256 hash.

Parameter Type Description
data Uint8Array Data to hash.
key Uint8Array Secret key.

Returns: Uint8Array — The HMAC-SHA256 data.

Examples

How to use.

const data = Uint8Array.from([104, 101, 108, 108, …])
const key =  Uint8Array.from([193, 208, 122, 108, …])

hmac_sha256(data, key).then(console.log)

The logged output is UintArray([43, …])

changelog

UNIVERSAL-HMAC-SHA256-JS

V 3.0.1

Patch

  • Readme typo fixes.

V 3.0.0

Major

  • Split deno and node js hmac-sha256 packages into separate files to prevent network access prompts in deno.

V 2.0.0

Major

  • Changed from CJS to ESM
  • Imports now require deep imports

V 1.0.0

  • Initial release