Skip to content
ufraan
← Back

JWT HS256 RS256

Minimal Node.js JWT library with native crypto, supporting HS256 and RS256.

JavaScriptLibrary
Mar 2026GitHubLive

This one started because I kept pulling in heavy JWT packages for what should be a trivial operation. I wrote a minimal JWT library for Node.js that uses the native crypto module instead of external dependencies. It supports both HS256 symmetric and RS256 asymmetric signing algorithms, with sign, verify, and decode operations. The library includes constant-time signature comparison to prevent timing attacks, standard claims validation for exp, nbf, and iat, and configurable clock tolerance for handling minor time drift between systems.

JWT token signing flow diagram
JWT token signing flow diagram

Everything is built on top of the Node.js native crypto module with zero external dependencies. The API is split into separate paths for HMAC and RSA algorithms, and all cryptographic operations use constant-time comparison to avoid side-channel vulnerabilities.