
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
@otplib/plugin-crypto-noble
Advanced tools
Pure JavaScript crypto implementation using noble-hashes for otplib
Pure JavaScript crypto plugin for otplib using @noble/hashes.
npm install @otplib/plugin-crypto-noble
pnpm add @otplib/plugin-crypto-noble
yarn add @otplib/plugin-crypto-noble
This plugin provides HMAC and random byte generation using the @noble/hashes library - a zero-dependency, audited cryptographic implementation in pure JavaScript. It supports all standard hash algorithms:
sha1sha256sha512import { generateSecret, generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-noble";
import { base32 } from "@otplib/plugin-base32-scure";
// Generate a secret
const secret = generateSecret({ crypto, base32 });
// Generate a token
const token = await generate({
secret,
crypto,
base32,
});
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-noble";
import { base32 } from "@otplib/plugin-base32-scure";
const token = await generate({
secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
algorithm: "sha256",
crypto,
base32,
});
The noble crypto plugin supports both synchronous and asynchronous HMAC operations:
import { crypto } from "@otplib/plugin-crypto-noble";
// Sync HMAC (useful for high-volume operations)
const digest = crypto.hmacSync("sha1", key, data);
// Async HMAC (consistent API with web crypto)
const digest = await crypto.hmac("sha1", key, data);
Use this plugin when:
| Feature | plugin-crypto-noble | plugin-crypto-node | plugin-crypto-web |
|---|---|---|---|
| Node.js | Yes | Yes | No |
| Browser | Yes | No | Yes |
| Edge Runtime | Yes | No | Yes |
| Sync HMAC | Yes | Yes | No |
| Pure JS | Yes | No | No |
| Dependencies | @noble/hashes | None | None |
The @noble/hashes library adds approximately 15KB (gzipped) to your bundle. For browser applications where bundle size is critical, consider using @otplib/plugin-crypto-web instead.
Full documentation available at otplib.yeojz.dev:
FAQs
Pure JavaScript crypto implementation using noble-hashes for otplib
The npm package @otplib/plugin-crypto-noble receives a total of 1,445,947 weekly downloads. As such, @otplib/plugin-crypto-noble popularity was classified as popular.
We found that @otplib/plugin-crypto-noble demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.