{"id":22107481,"url":"https://github.com/nextyfine-dev/crypto-subtle-shield","last_synced_at":"2025-03-24T03:22:17.351Z","repository":{"id":211468504,"uuid":"729239263","full_name":"nextyfine-dev/crypto-subtle-shield","owner":"nextyfine-dev","description":"CryptoSubtleShield is a Node.js library for easy encryption and decryption using various algorithms. It provides a convenient interface to Node.js's built-in crypto module and offers additional features for enhanced control and security.","archived":false,"fork":false,"pushed_at":"2023-12-16T18:10:09.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T01:55:30.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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-08T17:34:17.000Z","updated_at":"2023-12-08T17:46:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"f59c7500-4783-4001-984f-f306677919b2","html_url":"https://github.com/nextyfine-dev/crypto-subtle-shield","commit_stats":null,"previous_names":["nextyfine-dev/crypto-subtle-shield"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-subtle-shield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-subtle-shield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-subtle-shield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fcrypto-subtle-shield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextyfine-dev","download_url":"https://codeload.github.com/nextyfine-dev/crypto-subtle-shield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245201224,"owners_count":20576779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-01T08:17:49.083Z","updated_at":"2025-03-24T03:22:17.336Z","avatar_url":"https://github.com/nextyfine-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CryptoSubtleShield 🛡️\n\nCryptoSubtleShield is a Node.js library for easy encryption and decryption using various algorithms. It provides a convenient interface to Node.js's built-in crypto module and offers additional features for enhanced control and security.\n\n## Table of Contents\n\n- [CryptoSubtleShield 🛡️](#cryptosubtleshield-️)\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    - [Basic Usage](#basic-usage)\n      - [CommonJS](#commonjs)\n      - [ES6 Module](#es6-module)\n    - [File Encryption](#file-encryption)\n      - [CommonJS](#commonjs-1)\n      - [ES6 Module](#es6-module-1)\n  - [API Documentation](#api-documentation)\n    - [`CryptoSubtleShield(options)`](#cryptosubtleshieldoptions)\n    - [`setSecretKey(secretKey)`](#setsecretkeysecretkey)\n    - [`setAlgorithm(algorithm, keyLength)`](#setalgorithmalgorithm-keylength)\n    - [`encryptText(text, secret?)`](#encrypttexttext-secret)\n    - [`decryptText(encryptedText, secret?)`](#decrypttextencryptedtext-secret)\n    - [`encryptFile(inputFilePath, outputFilePath?, secret?)`](#encryptfileinputfilepath-outputfilepath-secret)\n    - [`decryptFile(encryptedFilePath, outputFilePath?, secret?)`](#decryptfileencryptedfilepath-outputfilepath-secret)\n    - [`EncryptDecryptOptions`](#encryptdecryptoptions)\n  - [License](#license)\n\n## Features\n\n- 🚀 Encrypt and decrypt text.\n- 📁 Encrypt and decrypt files.\n- 🔐 Supports multiple encryption algorithms (AES-CBC, AES-GCM).\n- 🛠️ Customizable encryption options.\n- 🔑 Uses PBKDF2 for key derivation.\n- ⚙️ Options for key length, tag length, encoding, and more.\n  ...\n\n## Installation\n\nTo install CryptoSubtleShield, use npm, yarn or bun:\n\n```bash\nnpm install crypto-subtle-shield\n```\n\n```bash\nyarn add crypto-subtle-shield\n```\n\n```bash\nbun add crypto-subtle-shield\n```\n\n## Usage\n\n### Initialization\n\n```javascript\n// CommonJS\nconst CryptoSubtleShield = require(\"crypto-subtle-shield\");\nconst cryptoShield = new CryptoSubtleShield();\n\n// ESM\nimport CryptoSubtleShield from \"crypto-subtle-shield\";\nconst cryptoShield = new CryptoSubtleShield();\n```\n\n### Setting the Secret Key\n\n```javascript\nconst secretKey = \"my-secret-key\";\n\n// Set the key while initialize\nconst cryptoShield = new CryptoSubtleShield({ secretKey });\n\n// OR\n\n// Add secretKey after initialize it.\nconst cryptoShield = new CryptoShield();\ncryptoShield.setSecretKey(secretKey);\n\n// OR\n\n// pass secretKey while encrypting or decrypting\nawait cryptoShield.encryptText(text, \"your-secret-key\");\n```\n\n### Basic Usage\n\n#### CommonJS\n\n```typescript\nconst CryptoSubtleShield = require(\"crypto-subtle-shield\");\n\nconst cryptoShield = new CryptoSubtleShield();\n\nconst plaintext = \"Hello, CryptoSubtleShield!\";\nconst encryptedText = await cryptoShield.encryptText(\n  plaintext,\n  \"your-secret-key\"\n);\nconsole.log(\"Encrypted:\", encryptedText);\n\nconst decryptedText = await cryptoShield.decryptText(\n  encryptedText,\n  \"your-secret-key\"\n);\nconsole.log(\"Decrypted:\", decryptedText);\n```\n\n#### ES6 Module\n\n```typescript\nimport CryptoSubtleShield from \"crypto-subtle-shield\";\n\nconst cryptoShield = new CryptoSubtleShield();\n\ncryptoShield.setSecretKey(\"your-secret-key\");\n\nconst plaintext = \"Hello, CryptoSubtleShield!\";\nconst encryptedText = await cryptoShield.encryptText(plaintext);\nconsole.log(\"Encrypted:\", encryptedText);\n\nconst decryptedText = await cryptoShield.decryptText(encryptedText);\nconsole.log(\"Decrypted:\", decryptedText);\n```\n\n### File Encryption\n\n#### CommonJS\n\n```typescript\nconst CryptoSubtleShield = require(\"crypto-subtle-shield\");\n\nconst secretKey = \"your-secret-key\";\n\nconst cryptoShield = new CryptoSubtleShield({ secretKey });\n\nconst inputFile = \"path/to/your/file.txt\";\nconst encryptedFile = \"path/to/your/encrypted/file.txt\";\n\nawait cryptoShield.encryptFile(inputFile, encryptedFile);\nconsole.log(\"File Encrypted:\", encryptedFile);\n\nconst decryptedFile = \"path/to/your/decrypted/file.txt\";\nawait cryptoShield.decryptFile(encryptedFile, decryptedFile);\nconsole.log(\"File Decrypted:\", decryptedFile);\n```\n\n#### ES6 Module\n\n```typescript\nimport CryptoSubtleShield from \"crypto-subtle-shield\";\n\nconst cryptoShield = new CryptoSubtleShield();\n\nconst inputFile = \"path/to/your/file.txt\";\nconst encryptedFile = \"path/to/your/encrypted/file.txt\";\n\nawait cryptoShield.encryptFile(inputFile, encryptedFile, \"your-secret-key\");\nconsole.log(\"File Encrypted:\", encryptedFile);\n\nconst decryptedFile = \"path/to/your/decrypted/file.txt\";\nawait cryptoShield.decryptFile(encryptedFile, decryptedFile, \"your-secret-key\");\nconsole.log(\"File Decrypted:\", decryptedFile);\n```\n\n## API Documentation\n\n### `CryptoSubtleShield(options)`\n\nCreates a new instance of CryptoSubtleShield.\n\n- `options` (optional): An object with configuration options. See [EncryptDecryptOptions](#encryptdecryptoptions) for details.\n\n### `setSecretKey(secretKey)`\n\nSets the secret key for encryption and decryption.\n\n- `secretKey`: The secret key to set.\n\n### `setAlgorithm(algorithm, keyLength)`\n\nSets the encryption algorithm and key length.\n\n- `algorithm`: The encryption algorithm (AES-CBC or AES-GCM).\n- `keyLength`: The key length (128, 192, or 256).\n\n### `encryptText(text, secret?)`\n\nEncrypts a text string.\n\n- `text`: The text to encrypt.\n- `secret` (optional): The secret key. If not provided, the instance's secret key is used.\n\nReturns a Promise that resolves to the encrypted text.\n\n### `decryptText(encryptedText, secret?)`\n\nDecrypts an encrypted text string.\n\n- `encryptedText`: The text to decrypt.\n- `secret` (optional): The secret key. If not provided, the instance's secret key is used.\n\nReturns a Promise that resolves to the decrypted text.\n\n### `encryptFile(inputFilePath, outputFilePath?, secret?)`\n\nEncrypts a file.\n\n- `inputFilePath`: The path to the input file.\n- `outputFilePath` (optional): The path to the output file. If not provided, the input file is overwritten.\n- `secret` (optional): The secret key. If not provided, the instance's secret key is used.\n\nReturns a Promise that resolves when the file is successfully encrypted.\n\n### `decryptFile(encryptedFilePath, outputFilePath?, secret?)`\n\nDecrypts an encrypted file.\n\n- `encryptedFilePath`: The path to the encrypted file.\n- `outputFilePath` (optional): The path to the output file. If not provided, the decrypted file is overwritten.\n- `secret` (optional): The secret key. If not provided, the instance's secret key is used.\n\nReturns a Promise that resolves when the file is successfully decrypted.\n\n### `EncryptDecryptOptions`\n\nAn object with configuration options for CryptoSubtleShield.\n\n- `algorithm` (optional): The encryption algorithm (AES-CBC or AES-GCM). Default is AES-GCM.\n- `secretKey` (optional): The secret key for encryption and decryption. If not provided, it must be set later using `setSecretKey`.\n- `keyUsages` (optional): An array of key usages (encrypt, decrypt, etc.). Default is ['encrypt', 'decrypt'].\n- `extractable` (optional): Whether the key should be extractable. Default is false.\n- `keyType` (optional): The type of key to import. Default is 'raw'.\n- `keyLength` (optional): The key length (128, 192, or 256). Default is 256.\n- `tagLength` (optional): The tag length for authentication (32, 64, or 128). Default is 128.\n- `encoding` (optional): The encoding for text conversion. Default is 'hex'.\n- `iterations` (optional): The number of iterations\n\nfor PBKDF2 key derivation. Default is 1000.\n\n- `salt` (optional): The length of the salt for PBKDF2 key derivation. Default is 16.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fcrypto-subtle-shield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextyfine-dev%2Fcrypto-subtle-shield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fcrypto-subtle-shield/lists"}