Files
Failed to load latest commit information.
rules
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||
--- description: General information based on the latest ./README.md content globs: --- # ts-security > A comprehensive TypeScript security library providing cryptographic primitives and utilities with a focus on type safety, security, performance, and modern best practices. ## Features - 🔒 **Cryptographic Primitives** - AES encryption _(128/192/256-bit)_ with multiple modes _(ECB, CBC, CFB, OFB, CTR, GCM)_ - SHA-2 family hash functions _(SHA-256, SHA-384, SHA-512)_ - HMAC message authentication - RSA encryption and signing - Ed25519 digital signatures - 🛡️ **Secure Random Number Generation** - Fortuna CSPRNG implementation - Multiple entropy sources - Automatic reseeding - Browser and Bun / Node.js support - 📜 **Certificate Management** - X.509 certificate handling - PEM encoding/decoding - Certificate signing request _(CSR)_ creation - Certificate chain validation - 🔐 **TLS/SSL Support** - TLS protocol implementation - Secure socket connections - Certificate-based authentication - Modern cipher suite support - 🎯 **Type Safety** - Full TypeScript support - Comprehensive type definitions - Strict type checking - Modern ES6+ features - 🧰 **Utilities** - Base-N encoding _(Base64, Base58, etc.)_ - ASN.1 encoding/decoding - BigInteger arithmetic - Buffer manipulation ## Install ```bash # bun bun install ts-security # npm npm install ts-security # pnpm pnpm install ts-security ``` ## Get Started After installing the package, you can import and use the various cryptographic functions: ```ts import { aes, sha256, sha512, random, hmac, rsa, ed25519, pki, tls } from 'ts-security' // AES Encryption const cipher = aes.createCipher('AES-GCM', key) cipher.start({ iv: iv }) cipher.update(data) const encrypted = cipher.finish() // SHA-256 Hashing const md = sha256.create() md.update('Hello, World!') const hash = md.digest().toHex() // Secure Random Numbers const bytes = random.getBytesSync(32) // RSA Key Generation const keypair = rsa.generateKeyPair({ bits: 2048 }) // Digital Signatures const signature = ed25519.sign(message, privateKey) const isValid = ed25519.verify(signature, message, publicKey) // Certificate Operations const cert = pki.createCertificate() cert.publicKey = keypair.publicKey cert.sign(keypair.privateKey) // TLS Connections const connection = tls.connect({ server: host, port: 443, caStore: [/* trusted certificates */] }) ```