JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 43
  • Score
    100M100P100Q60845F
  • License MIT

Zero-dependency quantum-resistant AES-256-GCM encryption for text, files & WebRTC E2EE

Package Exports

  • webcrypt

Readme

webcrypt

Zero-dependency • Quantum-resistant • End-to-End Encryption
AES-256-GCM for text, files, and real-time WebRTC video/audio.

Works everywhere — no build step required.

npm install webcrypt
import { WebCrypt } from "webcrypt";

const wc = new WebCrypt();

Works in: Browser • Node.js • React • Next.js • Vue • Svelte • Electron • Deno • Cloudflare Workers

Features

Feature Status Details
Text encryption Done Returns base64 string
File encryption Done Streaming — handles 10 GB+ files
File decryption Done Restores original filename
WebRTC E2EE (video + audio) Done Insertable Streams — true end-to-end
Zero dependencies Done Pure Web Crypto API
Node.js 18+ support Done Native crypto.webcrypto
Quantum-resistant Done 600k PBKDF2 + random salts
Key caching Done Same password = instant reuse
TypeScript support Done Full .d.ts included

Installation

npm install webcrypt
# or
yarn add webcrypt
# or
pnpm add webcrypt

Usage

  1. Encrypt & Decrypt Text
import { WebCrypt } from "webcrypt";

const wc = new WebCrypt();

const secret = "The treasure is buried under the old oak tree";

const encrypted = await wc.encryptText(secret, "my-super-secret-password");
console.log(encrypted);
// → long base64 string

const decrypted = await wc.decryptText(encrypted, "my-super-secret-password");
console.log(decrypted);
// → "The treasure is buried under the old oak tree"
  1. Encrypt & Decrypt Files (streaming, low memory)
<input type="file" id="fileInput" />
<input type="password" id="pass" placeholder="Password" />
<button onclick="encrypt()">Encrypt File</button>
const wc = new WebCrypt();

async function encrypt() {
  const file = document.getElementById("fileInput").files[0];
  const password = document.getElementById("pass").value;

  const { blob, filename } = await wc.encryptFile(file, password);

  const a = document.createElement("a");
  a.href = URL.createObjectURL(blob);
  a.download = filename;
  a.click();
}

// Decryption is identical — just call decryptFile()
  1. End-to-End Encrypted WebRTC Video Call
const wc = new WebCrypt();
const CALL_PASSWORD = "our-private-call-2025";

const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
document.getElementById("localVideo").srcObject = stream;

const pc = new RTCPeerConnection();

// Encrypt everything we send
stream.getTracks().forEach(async track => {
  const sender = pc.addTrack(track, stream);
  sender.transform = new RTCRtpScriptTransform(await wc.createEncryptTransform(CALL_PASSWORD));
});

// Decrypt everything we receive
pc.ontrack = async event => {
  const receiver = event.receiver;
  receiver.transform = new RTCRtpScriptTransform(await wc.createDecryptTransform(CALL_PASSWORD));
  document.getElementById("remoteVideo").srcObject = event.streams[0];
};

Both users use the exact same password → SFU/server sees only encrypted garbage.

API

const wc = new WebCrypt()

wc.encryptText(text: string, password: string): Promise<string>
wc.decryptText(b64: string, password: string): Promise<string>

wc.encryptFile(file: File|Blob, password: string): Promise<{ blob: Blob, filename: string }>
wc.decryptFile(file: File|Blob, password: string): Promise<{ blob: Blob, filename: string }>

wc.createEncryptTransform(password: string): Promise<TransformFunction>
wc.createDecryptTransform(password: string): Promise<TransformFunction>

Security

AES-256-GCM (authenticated encryption)
600,000 PBKDF2-SHA256 iterations (OWASP 2025 compliant)
Unique 128-bit salt per message/file
Unique 96-bit IV per chunk/frame
No keys ever leave your device

Even quantum computers cannot break this in your lifetime.

Browser Support

Chrome 80+ • Edge 80+ • Firefox 90+ • Safari 15+ All support Web Crypto API + Insertable Streams.

Node.js Support

Works natively in Node.js 18+ via built-in crypto.webcrypto.

const { WebCrypt } = require("webcrypt");

License

MIT License — free for personal and commercial use
© 2025 Lucas Armstrong
https://github.com/lucasarmstrong/webcrypt

No telemetry. No servers. No backdoors.
Just pure, unbreakable encryption that works offline, forever.

Star this repo if you believe in private communication.

Made with passion for a freer, safer internet.