npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sebastienrousseau/crypto-react

v0.0.35

Published

React hooks for client-side cryptography: key generation, encryption, signing, hashing and post-quantum hybrid streaming encryption (ML-KEM-768).

Readme


Contents

Getting started

  • Install — installation via pnpm, npm, or yarn
  • Requirements — runtime floor and environment prerequisites
  • Quick Start — minimal working usage sample

The Crypto Service ecosystem

Package reference

Operational


Install

pnpm add @sebastienrousseau/crypto-react
# or
npm install @sebastienrousseau/crypto-react
# or
yarn add @sebastienrousseau/crypto-react

Requirements

  • Node.js: ^22.0.0 or >=24.0.0 (active and maintenance LTS releases)
  • Package Manager: pnpm >=9 (recommended) or npm >=10
  • TypeScript: >=5.0 (when compiling with TypeScript)

Quick Start

import {
  CryptoProvider,
  useKeypair,
  useEncrypt,
  useHash,
  useSignature,
} from "@sebastienrousseau/crypto-react";

function App() {
  return (
    <CryptoProvider defaultKey="deadbeef...64-hex-chars">
      <MyComponent />
    </CryptoProvider>
  );
}

function MyComponent() {
  const { generate, publicKey } = useKeypair("ed25519");
  const { encrypt, decrypt } = useEncrypt();
  const { hash, digest } = useHash("sha3-256");
  const { sign, verify } = useSignature();

  return (
    <div>
      <button onClick={() => generate()}>Generate Ed25519 Key Pair</button>
      {publicKey && <code>{publicKey}</code>}
    </div>
  );
}

The Crypto Service ecosystem

Crypto Service provides a complete cryptography stack across 14 specialized packages:

| Package | Role | Description | | :-------------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :----------------------------------------------------------------------------------------------------------------------------- | | @sebastienrousseau/crypto-api | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. | | @sebastienrousseau/crypto-benchmarks | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. | | @sebastienrousseau/crypto-cbom | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). | | @sebastienrousseau/crypto-cli | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. | | @sebastienrousseau/crypto-edge | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. | | @sebastienrousseau/crypto-kms | Cloud KMS | Unified KMS interface: AWS KMS and local providers implemented; GCP, Azure and Vault are stubs. | | @sebastienrousseau/crypto-lib | Core Library | Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript. | | @sebastienrousseau/crypto-lsp | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. | | @sebastienrousseau/crypto-mcp | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. | | @sebastienrousseau/crypto-middleware | Middleware | Cryptographic middleware for Express and Fastify: decrypt requests, encrypt responses, verify HMAC signatures and JWTs. | | @sebastienrousseau/crypto-prisma | ORM Adapter | Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305. | | @sebastienrousseau/crypto-react (this package) | React Hooks | React hooks and context provider for client-side cryptographic operations with zero boilerplate. | | @sebastienrousseau/crypto-sdk | Client SDK | A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support. | | @sebastienrousseau/crypto-server | HTTP API | A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints. | | @sebastienrousseau/crypto-testing | Test Support | Deterministic keys, fast mocks, and test fixtures for crypto-lib | | @sebastienrousseau/crypto-typeorm | ORM Adapter | TypeORM column-level encryption with a single decorator, powered by crypto-lib. | | @sebastienrousseau/crypto-vue | Vue Composables | Vue 3 composables for client-side cryptography | | @sebastienrousseau/crypto-wasm | Acceleration | Placeholder for a WebAssembly accelerator; no WebAssembly module ships yet. |


Overview

crypto-react provides React hooks for client-side cryptographic operations. It wraps @sebastienrousseau/crypto-lib in a reactive API with hooks for key generation, symmetric encryption, hashing, and digital signatures. A CryptoProvider component supplies shared configuration (default key, server URL, API key) to all hooks via React context.

CryptoProvider

Wrap your component tree with <CryptoProvider> to supply shared configuration to all hooks.

<CryptoProvider
  defaultKey="a1b2c3d4...64-hex-chars"
  serverUrl="https://crypto.example.com"
  apiKey="my-api-key"
>
  <App />
</CryptoProvider>

| Prop | Type | Description | | :----------- | :---------- | :--------------------------------------- | | defaultKey | string | Hex-encoded 256-bit key for useEncrypt | | serverUrl | string | Server URL for SDK-backed operations | | apiKey | string | API key for server authentication | | children | ReactNode | Child components |

Access the context from any child via useCryptoContext().

Hooks Reference

| Hook | Purpose | Returns | | :------------- | :----------------------------------- | :------------------------------------------------------------- | | useKeypair | Key pair generation (all algorithms) | { publicKey, privateKey, algorithm, generate, isGenerating } | | useEncrypt | Symmetric encryption (secretbox) | { encrypt, decrypt, ciphertext, plaintext, isProcessing } | | useHash | Cryptographic hashing | { hash, digest, isHashing } | | useSignature | Digital signatures (sign + verify) | { sign, verify, signature, isValid, isProcessing } |

Usage

import { useKeypair } from "@sebastienrousseau/crypto-react";

function KeygenPage() {
  const { publicKey, generate, isGenerating } = useKeypair("ed25519");

  return (
    <div>
      <button onClick={() => generate()} disabled={isGenerating}>
        Generate Ed25519
      </button>
      {publicKey && <code>{publicKey.slice(0, 64)}...</code>}
    </div>
  );
}
import { useEncrypt } from "@sebastienrousseau/crypto-react";

function EncryptPage() {
  const { encrypt, decrypt, ciphertext, plaintext, isProcessing } =
    useEncrypt();

  return (
    <div>
      <button onClick={() => encrypt("secret message")} disabled={isProcessing}>
        Encrypt
      </button>
      {ciphertext && (
        <button onClick={() => decrypt(ciphertext)} disabled={isProcessing}>
          Decrypt
        </button>
      )}
      {plaintext && <p>Decrypted: {plaintext}</p>}
    </div>
  );
}
import { useHash } from "@sebastienrousseau/crypto-react";

function HashPage() {
  const { hash, digest, isHashing } = useHash("sha3-256");

  return (
    <div>
      <button onClick={() => hash("Hello")} disabled={isHashing}>
        SHA3-256
      </button>
      {digest && <code>{digest}</code>}
    </div>
  );
}
import { useKeypair, useSignature } from "@sebastienrousseau/crypto-react";

function SignPage() {
  const { publicKey, privateKey, generate } = useKeypair("ed25519");
  const { sign, verify, signature, isValid, isProcessing } = useSignature();

  return (
    <div>
      <button onClick={() => generate()}>Generate Keys</button>
      {privateKey && (
        <button
          onClick={() => sign(privateKey, "my message")}
          disabled={isProcessing}
        >
          Sign
        </button>
      )}
      {signature && publicKey && (
        <button
          onClick={() => verify(publicKey, "my message", signature)}
          disabled={isProcessing}
        >
          Verify
        </button>
      )}
      {isValid !== null && <p>Valid: {isValid ? "Yes" : "No"}</p>}
    </div>
  );
}

Examples

All examples are self-contained TypeScript files in the examples/ directory. Run any example with:

npx ts-node examples/<name>.ts

| Category | Example | Purpose | | :------------- | :---------------------------------- | :-------------------------------------------- | | Provider | provider.ts | CryptoProvider context setup and access | | Key Generation | keygen.ts | Generate Ed25519 and ML-DSA-65 key pairs | | Encryption | encrypt.ts | Secretbox encrypt and decrypt round-trip | | Hashing | hash.ts | SHA-256, SHA3-256, and BLAKE3 hashing | | Signing | sign.ts | Ed25519 sign and verify with tamper detection |


Development

pnpm --filter @sebastienrousseau/crypto-react run build
pnpm --filter @sebastienrousseau/crypto-react run test
pnpm --filter @sebastienrousseau/crypto-react run lint
pnpm --filter @sebastienrousseau/crypto-react run format

All 18 packages in the Crypto Service workspace maintain a 100% coverage floor across statements, branches, functions, and lines.


Security

Report vulnerabilities privately via GitHub Security Advisories or according to SECURITY.md. Never report security issues publicly.

Cryptographic operations use the @noble/* libraries, Node.js crypto and OpenPGP.js. @noble/post-quantum has not been independently audited and does not guarantee constant-time execution, and no module in this suite is FIPS 140-3 validated. Key zeroization is limited: JavaScript strings and garbage-collected buffers cannot be reliably wiped. See SECURITY.md.


Documentation


Stability guarantees

Versions advance strictly one step at a time on the 0.0.x line (v0.0.1 → v0.0.2 → v0.0.3 ... → v0.0.999 → v0.1.0). Work for every release iteration begins on a dedicated feat/v<version> branch.

All 18 packages in the workspace move in lockstep. Public API signatures, cipher output formats, and serialization schemas are strictly versioned. Breaking changes to serialized formats or algorithm defaults are considered major breaking changes. Minimum toolchain upgrades (e.g. Node.js LTS floor) are governed by POLICIES.md.


License

Dual-licensed under Apache 2.0 or MIT, at your option.

Copyright (c) 2022-2026 Sebastien Rousseau and The Crypto Service Suite contributors.