@oslojs/crypto documentation
Documentation: https://crypto.oslojs.dev
A basic JavaScript crypto library by Oslo. Includes APIs for SHA-1, SHA-2, HMAC, ECDSA, and cryptographically secure random generator.
- Runtime-agnostic
- No third-party dependencies
- Fully typed
Alongside @oslojs/encoding
and @oslojs/binary
, it aims to provide a basic toolbox for implementing auth and auth-related standards.
Installation
npm i @oslojs/crypto
Prerequisites
This package requires the Web Crypto API. This is available in most modern runtimes, including Node.js 20+, Deno, Bun, and Cloudflare Workers. The big exception is Node.js 16 and 18. Make sure to polyfill it using webcrypto
.
import { webcrypto } from "node:crypto";
globalThis.crypto = webcrypto;
Alternatively, add the --experimental-global-webcrypto
flag when executing files.
node --experimental-global-webcrypto index.js