
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
@otplib/hotp
Advanced tools
RFC 4226 HOTP implementation for otplib.
npm install @otplib/hotp
pnpm install @otplib/hotp
yarn add @otplib/hotp
import { generate, verify } from "@otplib/hotp";
import { NodeCryptoPlugin } from "@otplib/plugin-crypto-node";
import { ScureBase32Plugin } from "@otplib/plugin-base32-scure";
const crypto = new NodeCryptoPlugin();
const base32 = new ScureBase32Plugin();
// Generate an HOTP token for counter 0
const token = await generate({
secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
counter: 0,
crypto,
base32,
});
// Verify an HOTP token
const result = await verify({
secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
token: "123456",
counter: 0,
crypto,
base32,
counterTolerance: 0,
});
// result.valid: boolean
// result.delta: number | null
Generate an HOTP code for a specific counter:
import { generate } from '@otplib/hotp';
const token = await generate({
secret: new Uint8Array([...]), // Required: secret as bytes
counter: 0, // Required: counter value
crypto: new NodeCryptoPlugin(), // Required: crypto plugin
base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
algorithm: 'sha1', // Optional: 'sha1' | 'sha256' | 'sha512'
digits: 6, // Optional: 6 | 7 | 8
});
Verify an HOTP code:
import { verify } from '@otplib/hotp';
const result = await verify({
secret: new Uint8Array([...]), // Required: secret as bytes
token: '123456', // Required: token to verify
counter: 0, // Required: expected counter
crypto: new NodeCryptoPlugin(), // Required: crypto plugin
base32: new ScureBase32Plugin(), // Optional: base32 plugin (for decoding)
algorithm: 'sha1', // Optional: hash algorithm
digits: 6, // Optional: expected digits
counterTolerance: 5, // Optional: look-ahead tolerance
});
// Returns: { valid: boolean, delta: number | null }
Full documentation available at otplib.yeojz.dev:
MIT © 2026 Gerald Yeo
Speakeasy is a popular library for generating and verifying one-time passwords, including both HOTP and TOTP. It offers similar functionality to @otplib/hotp but also includes additional features like QR code generation for easier integration with mobile authenticator apps.
notp is a simple library for generating and verifying both HOTP and TOTP tokens. It is lightweight and easy to use, similar to @otplib/hotp, but may not have as many configuration options or additional features as otplib.
FAQs
RFC 4226 HOTP implementation for otplib
The npm package @otplib/hotp receives a total of 995,665 weekly downloads. As such, @otplib/hotp popularity was classified as popular.
We found that @otplib/hotp 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
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

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.