{"id":22107480,"url":"https://github.com/nextyfine-dev/crypto-shield","last_synced_at":"2026-04-29T09:01:41.380Z","repository":{"id":211337518,"uuid":"728860483","full_name":"nextyfine-dev/crypto-shield","owner":"nextyfine-dev","description":"CryptoShield is a powerful and efficient Node.js library designed for seamless encryption and decryption using a variety of algorithms. Leveraging Node.js's built-in crypto module, this library empowers users with fine-grained control over their encryption processes, ensuring both security and flexibility.","archived":false,"fork":false,"pushed_at":"2024-02-24T14:38:17.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T00:31:53.571Z","etag":null,"topics":["crypto","decryption","encryption","encryption-decryption","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/crypto-shield","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/nextyfine-dev.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}},"created_at":"2023-12-07T21:20:23.000Z","updated_at":"2023-12-07T22:01:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b535289-0469-4aa3-b1c5-e67f696879f3","html_url":"https://github.com/nextyfine-dev/crypto-shield","commit_stats":null,"previous_names":["nextyfine-dev/node-encrypt-decrypt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nextyfine-dev/crypto-shield","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-shield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-shield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-shield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-shield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextyfine-dev","download_url":"https://codeload.github.com/nextyfine-dev/crypto-shield/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-shield/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32418173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["crypto","decryption","encryption","encryption-decryption","nodejs"],"created_at":"2024-12-01T08:17:48.544Z","updated_at":"2026-04-29T09:01:41.343Z","avatar_url":"https://github.com/nextyfine-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛡️ crypto-shield\n\n**crypto-shield: Secure and Efficient Encryption and Decryption Library for Node.js**\n\ncrypto-shield is a powerful and efficient Node.js library designed for seamless encryption and decryption using a variety of algorithms. Leveraging Node.js's built-in crypto module, this library empowers users with fine-grained control over their encryption processes, ensuring both security and flexibility.\n\n## Table of Contents\n\n- [🛡️ crypto-shield](#️-crypto-shield)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Initialization](#initialization)\n    - [Setting the Secret Key](#setting-the-secret-key)\n    - [Encrypting and Decrypting Text](#encrypting-and-decrypting-text)\n    - [File Encryption and Decryption](#file-encryption-and-decryption)\n- [API Documentation](#api-documentation)\n  - [Class: CryptoShield](#class-cryptoshield)\n    - [new CryptoShield(options)](#new-cryptoshieldoptions)\n      - [Parameters](#parameters)\n    - [EncryptDecryptOptions](#encryptdecryptoptions)\n      - [Properties](#properties)\n    - [Usage](#usage-1)\n    - [setSecretKey(secret: string): void](#setsecretkeysecret-string-void)\n      - [Parameters](#parameters-1)\n    - [encryptText(text: string, secret?: string): Promise\\\u003c`string`\\\u003e](#encrypttexttext-string-secret-string-promisestring)\n      - [Parameters](#parameters-2)\n    - [decryptText(encryptedText: string, secret?: string): Promise\\\u003c`string`\\\u003e](#decrypttextencryptedtext-string-secret-string-promisestring)\n        - [Parameters](#parameters-3)\n    - [encryptFile(inputFilePath: string, outputFilePath?: string, secret?: string): Promise\\\u003c`boolean`\\\u003e](#encryptfileinputfilepath-string-outputfilepath-string-secret-string-promiseboolean)\n      - [Parameters](#parameters-4)\n    - [decryptFile(inputFilePath: string, outputFilePath?: string, secret?: string): Promise\\\u003c`boolean`\\\u003e](#decryptfileinputfilepath-string-outputfilepath-string-secret-string-promiseboolean)\n      - [Parameters](#parameters-5)\n  - [License](#license)\n\n## Features\n\n- 🚀 Encrypt and decrypt text effortlessly.\n- 📁 Encrypt and decrypt files securely.\n- 🔐 Supports a diverse set of encryption algorithms for enhanced security.\n- 🛠️ Customizable encryption options, allowing fine-tuning for specific use cases.\n- 🔑 Utilizes PBKDF2 for robust key derivation.\n- 🎯 Streamlined API for seamless integration into Node.js applications.\n- 🌐 Versatile support for both CommonJS (CJS) and ECMAScript Modules (ESM).\n- ⚡ Optimized performance ensures swift cryptographic operations.\n- 🛡️ Robust error handling for a reliable encryption and decryption experience.\n- 🤝 Well-documented and beginner-friendly, fostering ease of use.\n- 🌈 Compatible with a variety of Node.js projects, enhancing flexibility.\n- 🔄 Supports both asynchronous (async/await) and synchronous (Promise) programming paradigms.\n- 📦 Lightweight and dependency-free, keeping your project dependencies in check.\n- 🌐 Cross-platform compatibility for versatile deployment options.\n- 🛑 Thoroughly tested to ensure reliability and stability in diverse scenarios.\n\ncrypto-shield provides an extensive feature set to meet your encryption and decryption needs while offering simplicity, security, and flexibility in your Node.js projects.\n\n## Installation\n\nInstall the package using npm:\n\n```bash\nnpm install crypto-shield\n```\n\nInstall the package using yarn:\n\n```bash\nyarn add crypto-shield\n```\n\nInstall the package using bun:\n\n```bash\nbun add crypto-shield\n```\n\n## Usage\n\n### Initialization\n\n```javascript\n// CommonJS\nconst CryptoShield = require(\"crypto-shield\");\nconst encryptor = new CryptoShield();\n\n// ESM\nimport CryptoShield from \"crypto-shield\";\nconst encryptor = new CryptoShield();\n```\n\n### Setting the Secret Key\n\n```javascript\nconst secretKey = \"my-secret-key\";\n\n// Set the key while initialize\nconst encryptor = new CryptoShield({ secretKey });\n\n// OR\n\n// Add secretKey after initialize it.\nconst encryptor = new CryptoShield();\nencryptor.setSecretKey(secretKey);\n```\n\n### Encrypting and Decrypting Text\n\n```javascript\nconst plaintext = \"Hello, world!\";\n\n// Async/Await\n(async () =\u003e {\n  try {\n    const encryptedText = await encryptor.encryptText(plaintext);\n    console.log(\"Encrypted Text:\", encryptedText); // 3992b5bf64591ebbe93708ffb2dc00e8a481b93d4c2c1b752509525b05a4f24316a9d3e82556e61e79c6c129db31b62cf57a910a3c3b1d0d64ab0dc41a4eaa5ce948442365d2ce0280\n\n    const decryptedText = await encryptor.decryptText(encryptedText);\n    console.log(\"Decrypted Text:\", decryptedText); // Hello, world!\n  } catch (error) {\n    console.error(\"Error:\", error);\n  }\n})();\n\n// Promises\nencryptor\n  .encryptText(plaintext)\n  .then((encryptedText) =\u003e {\n    console.log(\"Encrypted Text:\", encryptedText);\n\n    return encryptor.decryptText(encryptedText);\n  })\n  .then((decryptedText) =\u003e {\n    console.log(\"Decrypted Text:\", decryptedText);\n  })\n  .catch((error) =\u003e {\n    console.error(\"Error:\", error);\n  });\n```\n\n### File Encryption and Decryption\n\n```javascript\nconst inputFile = \"input.txt\";\nconst outputFile = \"output.txt\";\nconst secretKey = \"my-secret-key\";\n\nencryptor.setSecretKey(secretKey);\n\n// Async/Await\n(async () =\u003e {\n  try {\n    await encryptor.encryptFile(inputFile, outputFile);\n    console.log(\"File encrypted successfully\");\n\n    await encryptor.decryptFile(outputFile);\n    console.log(\"File decrypted successfully\");\n  } catch (error) {\n    console.error(\"Error:\", error);\n  }\n})();\n\n// Promises\nencryptor\n  .encryptFile(inputFile, outputFile)\n  .then(() =\u003e console.log(\"File encrypted successfully\"))\n  .then(() =\u003e encryptor.decryptFile(outputFile))\n  .then(() =\u003e console.log(\"File decrypted successfully\"))\n  .catch((error) =\u003e console.error(\"Error:\", error));\n```\n\n# API Documentation\n\n## Class: CryptoShield\n\n### new CryptoShield(options)\n\nCreates an instance of the CryptoShield class.\n\n#### Parameters\n\n- `options` (optional): `EncryptDecryptOptions` - An object with configuration options.\n\n### EncryptDecryptOptions\n\nThe `EncryptDecryptOptions` interface defines the configuration options available when initializing an instance of the `CryptoShield` class.\n\n#### Properties\n\n- `algorithm` (optional): Specifies the encryption algorithm to be used. Choose from the supported algorithms defined in `EncryptionAlgorithm`. Default is `\"aes-256-gcm\"`.\n- `iterations` (optional): The number of iterations for the key derivation function (PBKDF2). Default is `5000`.\n\n- `keyLength` (optional): The length of the encryption key. Choose from the common key lengths defined in `KeyLength`. Default is `32`.\n\n- `ivLength` (optional): The length of the initialization vector (IV) used in the encryption process. Default is `12`.\n\n- `tagLength` (optional): The length of the authentication tag used in some encryption algorithms. Choose from `AuthTagLength`. Default is `16`.\n\n- `salt` (optional): The length of the salt used in the key derivation process. Default is `32`.\n\n- `encoding` (optional): The encoding to be used for text representation. Default is `\"hex\"`.\n\n- `decoding` (optional): The encoding to be used for text decoding. Default is `\"utf8\"`.\n\n- `secretKey` (optional): The secret key used for encryption and decryption. If not provided, it can be set later using the `setSecretKey` method.\n\n- `pbkdf2Algorithm` (optional): The hash algorithm used in the key derivation process (PBKDF2). Choose from the supported algorithms defined in `Pbkdf2Algorithm`. Default is `\"sha512\"`.\n\n### Usage\n\n```typescript\nimport CryptoShield, { EncryptDecryptOptions } from \"crypto-shield\";\n\n// Example options\nconst options: EncryptDecryptOptions = {\n  algorithm: \"aes-128-gcm\",\n  iterations: 10000,\n  keyLength: 16,\n  ivLength: 16,\n  tagLength: 8,\n  salt: 64,\n  encoding: \"base64\",\n  decoding: \"utf-8\",\n  secretKey: \"my-secret-key\",\n  pbkdf2Algorithm: \"sha256\",\n};\n\n// Initialize CryptoShield with options\nconst encryptor = new CryptoShield(options);\n\n// Use encryptor instance with the provided options\n```\n\n### setSecretKey(secret: string): void\n\nSet the secret key for encryption and decryption.\n\n#### Parameters\n\n- `secret` (string): The secret key.\n\n### encryptText(text: string, secret?: string): Promise\u003c`string`\u003e\n\nEncrypts the given text.\n\n#### Parameters\n\n- `text` (string): The text to encrypt.\n- `secret` (optional, string): The secret key.\n\n### decryptText(encryptedText: string, secret?: string): Promise\u003c`string`\u003e\n\nDecrypts the given encrypted text.\n\n##### Parameters\n\n- `encryptedText` (string): The text to decrypt.\n- `secret` (optional, string): The secret key.\n\n### encryptFile(inputFilePath: string, outputFilePath?: string, secret?: string): Promise\u003c`boolean`\u003e\n\nEncrypts a file.\n\n#### Parameters\n\n- `inputFilePath` (string): The path to the input file.\n- `outputFilePath` (optional, string): The path to the output file. If not provided, the input file will be overwritten.\n- `secret` (optional, string): The secret key.\n\n### decryptFile(inputFilePath: string, outputFilePath?: string, secret?: string): Promise\u003c`boolean`\u003e\n\nDecrypts a file.\n\n#### Parameters\n\n- `inputFilePath` (string): The path to the input file.\n- `outputFilePath` (optional, string): The path to the output file. If not provided, the input file will be overwritten.\n- `secret` (optional, string): The secret key.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fcrypto-shield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextyfine-dev%2Fcrypto-shield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fcrypto-shield/lists"}