@mdkva/encryptionkit
v0.1.0
Published
MDKVA EncryptionKit provides clean, reliable, and easily accessible encryption options ideal for apps, AI systems, and automation projects.
Readme
🛠️ MDKVA EncryptionKit
A lightweight, high-performance, dependency-free cryptographic toolkit for Node.js. Built completely with modern ES Modules (ESM) and leveraging Node's native crypto engine, EncryptionKit bridges the gap between historical ciphers and modern industry-standard protocols.
Whether you need to securely encrypt user payloads with AES-256-GCM, manage asymmetric handshakes via RSA, or experiment with classical mathematical ciphers like the Hill or Playfair networks, EncryptionKit provides a clean, unified, and highly scannable API architecture.
🚀 Features
- Zero External Dependencies: Built entirely on Node.js native primitives for maximum security and performance.
- Modern ESM Native: Fully supports tree-shaking out of the box (
import/export). - Modular Architecture: Every algorithm lives in its own dedicated sub-module file, ensuring clean extension and maintainability.
- Comprehensive Suite: Spans everything from 1st-century Caesar shifts to modern authenticated block and stream ciphers.
📂 Project Structure
encryptionkit/
├── package.json # Configured with "type": "module"
├── index.js # Primary API aggregator (Unified Export)
├── encryptionkit.js # Internal bridge and configuration orchestrator
└── ciphers/ # Isolated algorithm modules
├── aes.js # Symmetric AES-256-GCM
├── rsa.js # Asymmetric Keypair & PKCS1
├── hash.js # SHA-256 & Keyed HMAC
├── monoalphabetic.js # Caesar, Shift, & Custom Substitution
├── playfair.js # 5x5 Matrix Digram Cipher
├── hill.js # Matrix Linear Algebra (2x2 Modular Inverse)
├── polyalphabetic.js # Vigenère Cipher
└── streamblock.js # RC4 Stream Engine & Feistel Block Network
💻 Installation & Setup
- Clone or copy the directory structure into your project.
- Ensure your project's
package.jsoncontains"type": "module"to support ES imports:
{
"name": "MDKVA",
"type": "module",
"scripts": {
"dev": "vite dev"
},
"dependencies": {
}
}
📖 API Documentation & Usage
1. Modern Production-Grade Cryptography
Symmetric Encryption (AES-256-GCM)
Uses authenticated encryption to guarantee both confidentiality and payload integrity. Returns a safe, colon-separated string string layout (iv:authTag:ciphertext).
import { encryptAES, decryptAES } from './encryptionkit/index.js';
const secretKey = "32_character_long_secret_key_!!!"; // Must be 32 bytes
const secretMessage = "Simplifying Life with Human-Centered Tech";
// Encryption
const encrypted = encryptAES(secretMessage, secretKey);
console.log('AES Output:', encrypted);
// Decryption
const decrypted = decryptAES(encrypted, secretKey);
console.log('Decrypted:', decrypted);
Asymmetric Encryption (RSA)
Perfect for key exchanges and small, highly secure data payloads.
import { generateRSAKeyPair, encryptRSA, decryptRSA } from './encryptionkit/index.js';
// Generate 2048-bit PKCS1 Keypair
const { publicKey, privateKey } = generateRSAKeyPair();
const encrypted = encryptRSA("Secure Handshake Payload", publicKey);
const decrypted = decryptRSA(encrypted, privateKey);
Hashing & HMAC
One-way transformations for integrity verification and API signatures.
import { hashSHA256, generateHMAC } from './encryptionkit/index.js';
const fileHash = hashSHA256("Target Data String");
const apiSignature = generateHMAC("PayloadData", "WebhookSecretKey");
2. Classical & Algorithmic Ciphers
Caesar / Arbitrary Shift Ciphers
import { encryptShift, decryptShift } from './encryptionkit/index.js';
const cipherText = encryptShift("Hello Space", 7); // Shifts alphabet by 7
const plainText = decryptShift(cipherText, 7);
Monoalphabetic Substitution
Requires a unique, pre-scrambled 26-character alphabet string mapping key.
const customAlphabet = "ZEBRASCDFGHIJKLMNOPQTUVWXY";
const encrypted = encryptMonoAlphabetic("Secret Message", customAlphabet);
const decrypted = decryptMonoAlphabetic(encrypted, customAlphabet);
Playfair Cipher
Encrypts digrams (pairs of characters) using a structural $5 \times 5$ matrix keyword. Automatically normalizes text by replacing 'J' with 'I' and injecting padding tokens ('X') where needed.
import { encryptPlayfair, decryptPlayfair } from './encryptionkit/index.js';
const key = "MONARCHY";
const encrypted = encryptPlayfair("GOLDMEDAL", key);
const decrypted = decryptPlayfair(encrypted, key);
Hill Cipher
An advanced algebraic cipher utilizing matrix multiplication modulo 26. The key parameter requires a mathematically invertible $2 \times 2$ matrix.
import { encryptHill, decryptHill } from './encryptionkit/index.js';
const invertibleMatrix = [
[5, 8],
[17, 3]
];
const encrypted = encryptHill("CODE", invertibleMatrix);
const decrypted = decryptHill(encrypted, invertibleMatrix);
Polyalphabetic (Vigenère) Cipher
Dynamically shifts characters across a rolling landscape using a repetitive keyword index.
import { encryptVigenere, decryptVigenere } from './encryptionkit/index.js';
const encrypted = encryptVigenere("Human Centered Tech", "FOCUS");
const decrypted = decryptVigenere(encrypted, "FOCUS");
3. Dedicated Architectural Components
Stream Cipher (RC4 Engine)
A fast, byte-oriented symmetric stream cipher leveraging a key-scheduling algorithm state machine wrapper.
import { encryptRC4, decryptRC4 } from './encryptionkit/index.js';
const hexEncrypted = encryptRC4("Streaming Data Payload", "SystemStreamKey");
const plainText = decryptRC4(hexEncrypted, "SystemStreamKey");
Block Cipher (Feistel Network)
A conceptual, multi-round pedagogical block transformation machine. Performs deterministic chunk slicing, padding via custom PKCS7 constraints, and multi-stage block scrambling based on a numeric integer key.
import { encryptBlockFeistel, decryptBlockFeistel } from './encryptionkit/index.js';
const numericKey = 43981; // 16-bit integer key
const encryptedHex = encryptBlockFeistel("Block Payload Structure", numericKey);
const decryptedText = decryptBlockFeistel(encryptedHex, numericKey);
🛠️ Performance & Security Notice
[!WARNING] While
aes,rsa, andhashmodules leverage production-grade primitives backed natively by OpenSSL via Node's internal engine, the classical and architectural modules (playfair,hill,monoalphabetic,rc4,feistel) are built for educational prototyping, algorithmic demonstrations, and simulation environments. Do not use classical ciphers to protect production financial or health metadata.
📜 License
MIT License. Designed with intentionality and built to empower everyday ambition. Feel free to expand, break down, and integrate these systems into your microservices.
