{"_id":"@bouzraa/files-protector","_rev":"2-d78aa98736538d61987cec6310adc73b","name":"@bouzraa/files-protector","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.8":{"name":"@bouzraa/files-protector","version":"1.0.8","keywords":["encryption","decryption","crypto","files","file"],"author":{"name":"Mohamed Bouzraa"},"license":"MIT","_id":"@bouzraa/files-protector@1.0.8","maintainers":[{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"}],"dist":{"shasum":"20616e162a2e924ea13f7cf03ba986c826da8ed4","tarball":"https://registry.npmjs.org/@bouzraa/files-protector/-/files-protector-1.0.8.tgz","fileCount":14,"integrity":"sha512-dfmz/H0nyf/2CgagLS2GFdR2de2oX2LYzyGDmrX9ogCbOU0pnvDIZYvrhOkVMGY5GdEes4czMewe9sCaBsEqTQ==","signatures":[{"sig":"MEUCICFDkNPUfIqfaDAB6Vl2N+g5jZuGaOL5oL4BXqEoi/MdAiEA8iJlZN/IobUO5n3wlAH6zpUsZJVDj4T1t3bVhaXGT80=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16445},"main":"dist/FilesProtector.js","types":"dist/FilesProtector.d.ts","gitHead":"f8afb57ab363aaf89e332e8f91e1b7f948c2cfbf","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"},"_npmVersion":"10.8.2","description":"A package for encrypting and decrypting files using various algorithms.","directories":{},"_nodeVersion":"22.5.1","dependencies":{"@types/crypto-js":"^4.2.2","@bouzraa/files-protector":"file:"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/jest":"^29.5.14","@types/node":"^22.5.0"},"_npmOperationalInternal":{"tmp":"tmp/files-protector_1.0.8_1739789870439_0.6969627887100127","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@bouzraa/files-protector","version":"1.1.0","keywords":["encryption","decryption","crypto","files","file"],"author":{"name":"Mohamed Bouzraa"},"license":"MIT","_id":"@bouzraa/files-protector@1.1.0","maintainers":[{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"}],"dist":{"shasum":"2bd4fb65ca1157cfb5218734f730f9cd4e6e186e","tarball":"https://registry.npmjs.org/@bouzraa/files-protector/-/files-protector-1.1.0.tgz","fileCount":14,"integrity":"sha512-GHFxVbLrbERR+QAGiOj1TWs8vCT1ezSqV2ZZD/SHwIijyAeQ+mHeA9lwa8Kf90uam9/OrP9nRcLig19d4ooY4A==","signatures":[{"sig":"MEUCIFR4cONCBl+VU6sfgGqJg/g4ZbP0dU3EjWcqL9sleVTdAiEAv0dia7uyM3md3rWAgN3Fk7baWoEgdUXwNgOjNpsElA0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17398},"main":"dist/FilesProtector.js","types":"dist/FilesProtector.d.ts","gitHead":"074ec35e44cc6958175a51f0705c49f7883e05ae","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"},"_npmVersion":"10.8.2","description":"A package for encrypting and decrypting files using various algorithms.","directories":{},"_nodeVersion":"22.5.1","dependencies":{"@types/crypto-js":"^4.2.2","@bouzraa/files-protector":"file:"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/jest":"^29.5.14","@types/node":"^22.5.0"},"_npmOperationalInternal":{"tmp":"tmp/files-protector_1.1.0_1739790332948_0.4395329090947928","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bouzraa/files-protector","version":"1.2.0","description":"A package for encrypting and decrypting files using various algorithms.","main":"dist/FilesProtector.js","types":"dist/FilesProtector.d.ts","scripts":{"build":"tsc","prepublishOnly":"npm run build"},"keywords":["encryption","decryption","crypto","files","file"],"author":{"name":"Mohamed Bouzraa"},"license":"MIT","devDependencies":{"@types/jest":"^29.5.14","@types/node":"^22.5.0","jest":"^29.7.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","typescript":"^5.5.4"},"dependencies":{"@types/crypto-js":"^4.2.2"},"_id":"@bouzraa/files-protector@1.2.0","gitHead":"ba68c4a2399792df62db3bda1a584ca9710cee41","_nodeVersion":"22.5.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-6oTWUSNL3IQDxG7mdDVV4gXF3UoLsBMg9vjmFphVcwD76YADyGShdDtM19utNyS1/J4zqdGdhXRlGK07k0RGlg==","shasum":"3f0255975348ff306c471e4526f4085b42abbb8c","tarball":"https://registry.npmjs.org/@bouzraa/files-protector/-/files-protector-1.2.0.tgz","fileCount":14,"unpackedSize":17356,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICK+5B6nj57mZFVqjoT8wantBnmMG87xRJkO4aAoBSPvAiEA2DAt7at+EDn0x5xIyOdN9aCyEqveBaO0xJL9dtADI2I="}]},"_npmUser":{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"},"directories":{},"maintainers":[{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/files-protector_1.2.0_1739791564663_0.8710450900196502"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-17T10:57:50.341Z","modified":"2025-02-17T11:26:05.067Z","1.0.8":"2025-02-17T10:57:50.595Z","1.1.0":"2025-02-17T11:05:33.116Z","1.2.0":"2025-02-17T11:26:04.842Z"},"author":{"name":"Mohamed Bouzraa"},"license":"MIT","keywords":["encryption","decryption","crypto","files","file"],"description":"A package for encrypting and decrypting files using various algorithms.","maintainers":[{"name":"medo2203","email":"mohamedbouzraa04@gmail.com"}],"readme":"# Files Protector\r\n\r\n**Files Protector** is a TypeScript/Node.js package that provides robust functionality for encrypting and decrypting files using various cryptographic algorithms. This package allows you to easily secure and restore files through AES encryption and decryption with initialization vectors for enhanced security.\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Encrypting a File](#encrypting-a-file)\r\n  - [Decrypting a File](#decrypting-a-file)\r\n- [API](#api)\r\n  - [FilesProtector](#filesprotector)\r\n- [Supported Algorithms](#supported-algorithms)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n## Installation\r\n\r\nTo install **Files Protector**, use npm:\r\n\r\n```bash\r\nnpm install files-protector\r\n```\r\n\r\n## Usage\r\n\r\n### Encrypting a File\r\n\r\n```typescript\r\nimport { FilesProtector } from \"files-protector\";\r\n\r\nconst encryptionKey = \"your-encryption-key-in-hex\";\r\nconst protector = new FilesProtector(encryptionKey);\r\n\r\nconst inputPath = \"path/to/your/input/file.txt\";\r\nconst outputPath = \"path/to/your/encrypted/file.enc\";\r\n\r\nprotector.encryptFile(inputPath, outputPath);\r\n```\r\n\r\n### Decrypting a File\r\n\r\n```typescript\r\nimport { FilesProtector } from \"files-protector\";\r\n\r\nconst encryptionKey = \"your-encryption-key-in-hex\";\r\nconst protector = new FilesProtector(encryptionKey);\r\n\r\nconst inputPath = \"path/to/your/encrypted/file.enc\";\r\nconst outputPath = \"path/to/your/decrypted/file.txt\";\r\n\r\nprotector.decryptFile(inputPath, outputPath);\r\n```\r\n\r\n## API\r\n\r\n### FilesProtector\r\n\r\n#### Constructor\r\n\r\n```typescript\r\nconstructor(encryptionKey: string, algorithm: string = \"aes-256-ctr\")\r\n```\r\n\r\n- **encryptionKey**: A hexadecimal string used for encryption and decryption.\r\n- **algorithm**: (optional) The algorithm to use for encryption. Default is \"aes-256-ctr\".\r\n\r\n#### Methods\r\n\r\n```typescript\r\nencryptFile(inputFilePath: string, outputFilePath: string): void\r\n```\r\n\r\nEncrypts the file at inputFilePath and writes the encrypted content to outputFilePath. Uses an initialization vector (IV) for enhanced security.\r\n\r\n```typescript\r\ndecryptFile(inputFilePath: string, outputFilePath: string): string\r\n```\r\n\r\nDecrypts the file at inputFilePath and writes the decrypted content to outputFilePath. Returns the output file path.\r\n\r\n#### Private Methods\r\n\r\nThe class also includes two private methods for internal use:\r\n\r\n- `private encrypt(buffer: Buffer): Buffer`\r\n- `private decrypt(encryptedBuffer: Buffer): Buffer`\r\n\r\nThese methods handle the actual encryption and decryption operations using initialization vectors for secure cryptographic operations.\r\n\r\n## Security Features\r\n\r\n- Utilizes initialization vectors (IV) for enhanced security\r\n- IV is automatically generated for each encryption operation\r\n- IV is stored with the encrypted data for proper decryption\r\n- Supports various AES encryption algorithms\r\n- Implements secure buffer handling\r\n\r\n## Supported Algorithms\r\n\r\nThe following algorithms are supported:\r\n\r\n- aes-256-ctr (default)\r\n- aes-192-ctr\r\n- aes-128-ctr\r\n- aes-256-cbc\r\n- aes-192-cbc\r\n- aes-128-cbc\r\n\r\nEnsure that your encryption key length matches the requirements for the selected algorithm.\r\n\r\n## Error Handling\r\n\r\nThe package includes comprehensive error handling:\r\n\r\n- File reading/writing errors are caught and logged\r\n- Encryption/decryption errors are properly handled\r\n- All errors are logged with appropriate messages\r\n- Errors are propagated to the caller for proper handling\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request. Make sure to:\r\n\r\n1. Follow the existing code style\r\n2. Add/update tests as needed\r\n3. Update documentation for any new features\r\n4. Ensure all tests pass before submitting\r\n\r\n## License\r\n\r\nThis package is licensed under the MIT License. See the LICENSE file for details.\r\n\r\n---\r\n\r\nFor more detailed documentation and updates, visit the project's repository.\r\n\r\n### Key Features:\r\n\r\n- **Type Safety**: Written in TypeScript for better development experience\r\n- **Secure Implementation**: Uses crypto module with initialization vectors\r\n- **Flexible**: Supports multiple encryption algorithms\r\n- **Error Handling**: Comprehensive error management\r\n- **Easy to Use**: Simple API for file encryption and decryption\r\n","readmeFilename":"README.md"}