{"id":50069793,"url":"https://github.com/sur-ser/symmetricmorph","last_synced_at":"2026-05-22T02:34:31.195Z","repository":{"id":290286369,"uuid":"973940361","full_name":"sur-ser/symmetricmorph","owner":"sur-ser","description":"High-performance symmetric stream cipher with dynamic masking, cascading feedback, built-in MAC, and chunked encryption support. Lightweight and dependency-free.","archived":false,"fork":false,"pushed_at":"2025-04-28T10:02:07.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T10:59:50.841Z","etag":null,"topics":["browser","cipher","crypto","encryption","javascript","lightweight","nodejs","npm-package","open-source","security","stream-cipher","stream-encryption","symmetric-encryption","typescript","web-workers"],"latest_commit_sha":null,"homepage":"https://github.com/sur-ser/symmetricmorph","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sur-ser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T02:44:39.000Z","updated_at":"2025-04-29T07:47:06.000Z","dependencies_parsed_at":"2025-04-28T03:21:36.579Z","dependency_job_id":"93603427-9c16-45b9-bef3-6b8d91711eaf","html_url":"https://github.com/sur-ser/symmetricmorph","commit_stats":null,"previous_names":["sur-ser/symmetricmorph"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sur-ser/symmetricmorph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sur-ser%2Fsymmetricmorph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sur-ser%2Fsymmetricmorph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sur-ser%2Fsymmetricmorph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sur-ser%2Fsymmetricmorph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sur-ser","download_url":"https://codeload.github.com/sur-ser/symmetricmorph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sur-ser%2Fsymmetricmorph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33325751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"online","status_checked_at":"2026-05-22T02:00:06.671Z","response_time":265,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","cipher","crypto","encryption","javascript","lightweight","nodejs","npm-package","open-source","security","stream-cipher","stream-encryption","symmetric-encryption","typescript","web-workers"],"created_at":"2026-05-22T02:34:27.724Z","updated_at":"2026-05-22T02:34:31.188Z","avatar_url":"https://github.com/sur-ser.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SymmetricMorph\n![npm](https://img.shields.io/npm/v/symmetricmorph)\n![GitHub](https://img.shields.io/github/license/sur-ser/symmetricmorph)\n![GitHub issues](https://img.shields.io/github/issues/sur-ser/symmetricmorph)\n[![Symmorph CLI](https://img.shields.io/badge/CLI-Available-green)](https://github.com/sur-ser/symmorph-cli)\n\n\nUnique symmetric stream cipher with dynamic masking, cascading feedback, chunked streaming support, and internal MAC.\n\n**SymmetricMorph** is a lightweight, dependency-free encryption library that provides:\n\n- High entropy stream output\n- Cascading feedback structure\n- Dynamic masking against known-plaintext attacks\n- Built-in MAC for integrity verification\n- Chunked encryption for large data streams\n- Works in **Node.js**, **browsers**, and **Web Workers**\n- Written in **TypeScript**, zero external dependencies\n\n---\n\n## 🚀 Universal Compatibility\n\nSymmetricMorph is designed to work seamlessly across a wide range of JavaScript environments:\n\n✅ Node.js (`require` and `import`)  \n✅ Browsers via `\u003cscript\u003e` (UMD)  \n✅ Browsers via `import` (ESM)  \n✅ Web Workers (background encryption)  \n✅ Full TypeScript type support  \n✅ No external dependencies  \n✅ Efficient for large file encryption\n\nPerfect for:\n\n- Node.js servers\n- Web applications\n- Mobile browsers\n- Desktop Electron apps\n- Progressive Web Apps (PWA)\n- Background data encryption with Web Workers\n- Embedded JavaScript runtimes (e.g., Deno)\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install symmetricmorph\n```\n\nor\n\n```bash\nyarn add symmetricmorph\n```\n\n---\n\n## 🌐 CDN Usage (Optional)\nYou can also load SymmetricMorph directly from a CDN without installing:\n\n**Using** unpkg:\n```html\n\u003cscript src=\"https://unpkg.com/symmetricmorph/dist/browser/symmetricmorph.umd.js\"\u003e\u003c/script\u003e\n```\nOr **using** jsDelivr:\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/symmetricmorph/dist/browser/symmetricmorph.umd.js\"\u003e\u003c/script\u003e\n```\nThen use it via global SymmetricMorph object in your scripts.\n\n\n---\n\n## ⚡ Quick Start\n\n\"**Important**: Always save the salt after encryption. It's required for correct decryption.\"\n\n### Node.js (CommonJS)\n\n```javascript\nconst SymmetricMorph = require('symmetricmorph').default;\n\n// Step 1: Encrypt\nconst cipherEnc = SymmetricMorph.fromPassword('MyStrongPassword');\nconst salt = cipherEnc.getSalt();\nconst plain = new Uint8Array(Array.from('Hello Node!').map(c =\u003e c.charCodeAt(0)));\nconst encrypted = cipherEnc.encrypt(plain);\n\n// Step 2: Decrypt using the saved salt\nconst cipherDec = SymmetricMorph.fromPasswordWithSalt('MyStrongPassword', salt);\nconst decrypted = cipherDec.decrypt(encrypted);\n\nconsole.log(String.fromCharCode(...decrypted)); // Hello Node!\n\n```\n\n### Node.js (ESM)\n\n```typescript\nimport SymmetricMorph from 'symmetricmorph';\n\n// Step 1: Encrypt\nconst cipherEnc = SymmetricMorph.fromPassword('MyStrongPassword');\nconst salt = cipherEnc.getSalt();\nconst plain = new Uint8Array(Array.from('Hello Node ESM!').map(c =\u003e c.charCodeAt(0)));\nconst encrypted = cipherEnc.encrypt(plain);\n\n// Step 2: Decrypt using the saved salt\nconst cipherDec = SymmetricMorph.fromPasswordWithSalt('MyStrongPassword', salt);\nconst decrypted = cipherDec.decrypt(encrypted);\n\nconsole.log(String.fromCharCode(...decrypted)); // Hello Node ESM!\n\n```\n\n---\n\n## 🌐 Browser Usage\n\n### Browser (UMD build)\n\n```html\n\u003cscript src=\"symmetricmorph.umd.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    // Step 1: Encrypt\n    const cipherEnc = SymmetricMorph.fromPassword('MyStrongPassword');\n    const salt = cipherEnc.getSalt();\n    const plain = new Uint8Array(Array.from('Hello Browser!').map(c =\u003e c.charCodeAt(0)));\n    const encrypted = cipherEnc.encrypt(plain);\n\n    // Step 2: Decrypt using the saved salt\n    const cipherDec = SymmetricMorph.fromPasswordWithSalt('MyStrongPassword', salt);\n    const decrypted = cipherDec.decrypt(encrypted);\n\n    console.log(String.fromCharCode(...decrypted)); // Hello Browser!\n\u003c/script\u003e\n```\n\n### Browser (ESM build)\n\n```html\n\u003cscript type=\"module\"\u003e\n  import SymmetricMorph from './symmetricmorph.es.js';\n\n  // Step 1: Encrypt\n  const cipherEnc = SymmetricMorph.fromPassword('Secret123');\n  const salt = cipherEnc.getSalt();\n  const plain = new Uint8Array(Array.from('Hello Browser!').map(c =\u003e c.charCodeAt(0)));\n  const encrypted = cipherEnc.encrypt(plain);\n\n  // Step 2: Decrypt using the saved salt\n  const cipherDec = SymmetricMorph.fromPasswordWithSalt('Secret123', salt);\n  const decrypted = cipherDec.decrypt(encrypted);\n\n  console.log(String.fromCharCode(...decrypted)); // Hello Browser!\n\u003c/script\u003e\n```\n\n---\n\n## 🧠 Background Encryption with Web Workers\n\nEncrypt large files in a Web Worker without blocking the main UI:\n\n```html\n\u003cscript\u003e\n    const worker = new Worker('./symmetricmorph-worker.js');\n\n    let savedSalt = null;\n    let encryptedData = null;\n\n    worker.postMessage({ type: 'init', password: 'StrongPassword123' });\n\n    worker.onmessage = (event) =\u003e {\n        const { type, encrypted, decrypted, salt } = event.data;\n\n        if (type === 'ready') {\n            console.log('Worker ready! Encrypting now...');\n            const plainText = 'This is a big secret message!';\n            const plainBytes = new Uint8Array(Array.from(plainText).map(c =\u003e c.charCodeAt(0)));\n\n            worker.postMessage({ type: 'encrypt', data: plainBytes });\n        }\n\n        if (type === 'encrypted') {\n            console.log('Encrypted data:', encrypted);\n            encryptedData = encrypted;\n            savedSalt = event.data.salt;\n\n            worker.postMessage({ type: 'decrypt', data: encryptedData, salt: savedSalt });\n        }\n\n        if (type === 'decrypted') {\n            console.log('Decrypted data:', String.fromCharCode(...decrypted));\n        }\n\n        if (type === 'error') {\n            console.error('Worker error:', event.data.message);\n        }\n    };\n\u003c/script\u003e\n```\n**and in `symmetricmorph-worker.js`:**\n\n```javascript\nimportScripts('../../../dist/browser/symmetricmorph.umd.js');\n\nlet cipher = null;\nlet currentPassword = null;\nlet currentSalt = null;\n\nself.addEventListener('message', (event) =\u003e {\n  const { type, password, data, salt } = event.data;\n\n  if (type === 'init') {\n    currentPassword = password;\n    cipher = SymmetricMorph.fromPassword(currentPassword);\n    currentSalt = cipher.getSalt();\n    postMessage({ type: 'ready' });\n  } else if (type === 'encrypt' \u0026\u0026 cipher) {\n    const encrypted = cipher.encrypt(data);\n    postMessage({ type: 'encrypted', encrypted, salt: currentSalt });\n  } else if (type === 'decrypt' \u0026\u0026 data \u0026\u0026 salt) {\n    const decryptCipher = SymmetricMorph.fromPasswordWithSalt(currentPassword, salt);\n    const decrypted = decryptCipher.decrypt(data);\n    postMessage({ type: 'decrypted', decrypted });\n  } else {\n    postMessage({ type: 'error', message: 'Invalid operation' });\n  }\n});\n```\n\n---\n\n## 🧩 Advanced Features\n\n### Chunked Encryption (Stream API)\n\nEncrypt and decrypt multiple chunks of data independently:\n\n```typescript\nimport SymmetricMorph from 'symmetricmorph';\n\nconst cipher = SymmetricMorph.fromPassword('ChunkyPassword');\nconst chunks = [\n  Array.from('First chunk').map(c =\u003e c.charCodeAt(0)),\n  Array.from('Second chunk').map(c =\u003e c.charCodeAt(0)),\n  Array.from('Third chunk').map(c =\u003e c.charCodeAt(0))\n];\n\nconst encryptedChunks = cipher.encryptChunks(chunks);\nconst decryptedChunks = cipher.decryptChunks(encryptedChunks);\n\nconsole.log(decryptedChunks.map(chunk =\u003e String.fromCharCode(...chunk)).join(' '));\n```\n\n### Random Key Generation\n\n```typescript\nimport SymmetricMorph from 'symmetricmorph';\n\nconst randomKey = SymmetricMorph.generateKey(64);\nconst cipher = SymmetricMorph.fromKey(randomKey);\n\nconst message = Array.from('Random key encryption!').map(c =\u003e c.charCodeAt(0));\nconst encrypted = cipher.encrypt(message);\nconst decrypted = cipher.decrypt(encrypted);\n\nconsole.log(String.fromCharCode(...decrypted)); // Random key encryption!\n```\n\n---\n\n## 📚 API Reference\n\n| Method | Description |\n|:---|:---|\n| `SymmetricMorph.fromPassword(password: string, iterations?: number, keyLength?: number)` | Creates a cipher instance from a password and generates a random salt. |\n| `SymmetricMorph.fromPasswordWithSalt(password: string, salt: Uint8Array \\| number[], iterations?: number, keyLength?: number)` | Creates a cipher instance from a password and a provided salt. |\n| `SymmetricMorph.fromKey(key: Uint8Array)` | Creates a cipher instance from a raw encryption key. |\n| `SymmetricMorph.generateKey(length?: number)` | Generates a secure random encryption key. |\n| `cipher.getSalt()` | Returns the salt used during password-based key derivation (or `undefined` if using a raw key). |\n| `cipher.encrypt(plainBytes: Uint8Array)` | Encrypts an array of bytes. |\n| `cipher.decrypt(encryptedBytes: Uint8Array)` | Decrypts an array of bytes and verifies integrity. |\n| `cipher.encryptChunks(chunks: Uint8Array[])` | Encrypts multiple data chunks. |\n| `cipher.decryptChunks(chunks: Uint8Array[])` | Decrypts multiple data chunks. |\n\n---\n\n## 📦 Also Available: SymmetricMorph CLI\n\nYou can encrypt and decrypt files easily from the command line using the official **[SymmetricMorph CLI](https://www.npmjs.com/package/symmorph-cli)**.\n✅ Simple usage:\n✅ Supports encryption and decryption of any files\n✅ Automatically handles salt and password securely\n✅ Lightweight and fast\n\nInstall globally:\n\n```bash\nnpm install -g symmorph-cli\n```\n\nUsage example:\n```bash\n# Encrypt a file\nsymmorph encrypt --input myfile.txt --output encrypted.bin --password \"MyStrongPassword\"\n\n# Decrypt a file\nsymmorph decrypt --input encrypted.bin --output decrypted.txt --password \"MyStrongPassword\"\n```\n➡️ Learn more: [https://github.com/sur-ser/symmorph-cli](https://github.com/sur-ser/symmorph-cli)\n\n---\n\n## 📄 License\n\nMIT License  \nCopyright (c) 2025\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsur-ser%2Fsymmetricmorph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsur-ser%2Fsymmetricmorph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsur-ser%2Fsymmetricmorph/lists"}