Skip to content

Latest commit

 

History

History
93 lines (62 loc) · 3.28 KB

File metadata and controls

93 lines (62 loc) · 3.28 KB

WebCrypt

Zero-dependency end-to-end cryptography suite for the modern web.

npm version license tests coverage

AES-256-GCM symmetric encryption, RSA-4096 hybrid asymmetric encryption, ECDH key agreement, digital signatures, JWE compact serialization (RFC 7516), and WebRTC insertable streams — built natively for browser and Node.js Web Crypto API environments.


Interactive Live Demo & Documentation


Installation

npm install webcrypt

Quick Start Code Examples

1. Symmetric Text Encryption (AES-256-GCM)

import { WebCrypt } from "webcrypt";
const wc = new WebCrypt();

const encrypted = await wc.encryptText("Secret message", "my-password");
const decrypted = await wc.decryptText(encrypted, "my-password");

2. Large File Streaming Encryption (8MB Chunking)

const { blob, filename } = await wc.encryptFile(file, "my-password", { parallelChunks: 4 });
const decrypted = await wc.decryptFile(blob, "my-password");

3. Public-Key Hybrid Encryption (RSA-4096)

import { WebCryptAsym } from "webcrypt";
const wca = new WebCryptAsym();

const keys = await wca.generateKeyPair(4096);
const encrypted = await wca.encryptText("Secret payload", keys.publicKey);
const decrypted = await wca.decryptText(encrypted, keys.privateKey);

4. ECDH Key Agreement & One-Step Encryption

const aliceKeys = await wca.generateECDHKeyPair("P-256");
const bobKeys = await wca.generateECDHKeyPair("P-256");

const encrypted = await wca.encryptWithECDH("Confidential data", bobKeys.publicKey);
const decrypted = await wca.decryptWithECDH(encrypted, bobKeys.privateKey, aliceKeys.publicKey);

5. Digital Signatures (ECDSA P-256 / RSA-PSS)

const signingKeys = await wca.generateSigningKeyPair("ECDSA", "P-256");
const signature = await wca.signText("Tamper-proof payload", signingKeys.privateKey);
const isValid = await wca.verifyText("Tamper-proof payload", signature, signingKeys.publicKey);

Complete API & Technical Documentation

For complete method signatures, options, and advanced usage, see our detailed documentation sub-documents:


License

MIT © PuterVision LLC