
Security Fundamentals
Turtles, Clams, and Cyber Threat Actors: Shell Usage
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
js-crypto-hmac
Advanced tools
Universal Module for HMAC (Hash-based Message Authentication Code) in JavaScript
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.
This library is designed to 'universally' provide HMAC (Hash-based Message Authentication Code) functions, i.e., it works both on most modern 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.
At your project directory, do either one of the following.
$ npm install --save js-crypto-hmac // npm
$ yarn add js-crypto-hmac // yarn
$ git clone https://github.com/junkurihara/jscu.git
$ cd js-crypto-utils/packages/js-crypto-hmac
& yarn build
Then you should import the package as follows.
import hmac from 'js-crypto-hmac'; // for npm
import hmac from 'path/to/js-crypto-hmac/dist/index.js'; // for github
The bundled file is also given as js-crypto-hmac/dist/jschmac.bundle.js
for a use case where the module is imported as a window.jschmac
object via script
tags.
const msg = ...; // Uint8Array of arbitrary length
const key = ...; // Uint8Array of 32 bytes (since SHA-256 is used)
const hash = 'SHA-256';
hmac.compute(key, msg, hash).then( (hmac) => {
// now you get a keyed-hash of msg in Uint8Array
});
const msg = ...; // Uint8Array of arbitrary length
const key = ...; // Uint8Array of 32 bytes (since SHA-256 is used)
const mac = ...; // computed keyed hash in Uint8Array
const hash = 'SHA-256';
hmac.verify(key, msg, mac, hash).then( (result) => {
// now you get true or false as the result of verification
});
Licensed under the MIT license, see LICENSE
file.
FAQs
Universal Module for HMAC (Hash-based Message Authentication Code) in JavaScript
The npm package js-crypto-hmac receives a total of 25,176 weekly downloads. As such, js-crypto-hmac popularity was classified as popular.
We found that js-crypto-hmac demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.