{"id":22772418,"url":"https://github.com/mthomason/encrypt","last_synced_at":"2025-10-27T22:36:09.281Z","repository":{"id":267569316,"uuid":"832908127","full_name":"mthomason/encrypt","owner":"mthomason","description":"Simple Python scripts to encrypt and decrypt files.","archived":false,"fork":false,"pushed_at":"2024-12-11T09:01:25.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T14:17:21.019Z","etag":null,"topics":["encryption","encryption-decryption","example","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","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/mthomason.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":"2024-07-24T01:21:32.000Z","updated_at":"2024-12-11T09:01:28.000Z","dependencies_parsed_at":"2024-12-11T05:26:13.371Z","dependency_job_id":"50f58dad-6162-4c68-93c2-5645d8fb3459","html_url":"https://github.com/mthomason/encrypt","commit_stats":null,"previous_names":["mthomason/encrypt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthomason%2Fencrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthomason%2Fencrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthomason%2Fencrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mthomason%2Fencrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mthomason","download_url":"https://codeload.github.com/mthomason/encrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246318000,"owners_count":20758079,"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":["encryption","encryption-decryption","example","python","python3"],"created_at":"2024-12-11T17:08:31.744Z","updated_at":"2025-10-27T22:36:09.175Z","avatar_url":"https://github.com/mthomason.png","language":"Python","readme":"# A Python Script for Encrypting and Decrypting Files\n\nThis script helps you encrypt and decrypt files or directories using strong AES-256-CBC encryption. You can choose between using a password or a key file, making it flexible for different use cases. Dynamic salt ensures that even the same password produces unique encryption results every time.\n\n## Features\n\n- **Key-Based Encryption**:\n  - Generate a 256-bit encryption key.\n  - Securely store keys in a file for repeated use.\n\n- **Password-Based Encryption**:\n  - Use a password to derive an encryption key with PBKDF2.\n  - Dynamic salt ensures unique keys even with the same password.\n\n- **File and Directory Support**:\n  - Encrypt or decrypt individual files.\n  - Recursively encrypt or decrypt all files in a directory.\n\n- **Safety Checks**:\n  - Prevent accidental encryption or decryption of critical directories (e.g., root or home).\n\n## Installation\n\n### Prerequisites\n\n- Python 3.7 or higher\n\n### Setup\n\n1. Clone the repository:\n\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd project-folder\n   ```\n\n2. Create a virtual environment and activate it:\n\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate\n   ```\n\n3. Install dependencies:\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## How to Use the Script\n\n### Generating a Key\n\nTo generate a new encryption key and save it to a file:\n\n```bash\npython src/encryptf.py --generate-key --key /path/to/keyfile.key\n```\n\nIf the file already exists, the script will stop and warn you.\n\n### Encrypting a File\n\nTo encrypt a single file using a key file:\n\n```bash\npython src/encryptf.py --encrypt --file /path/to/file.txt --key /path/to/keyfile.key\n```\n\nTo encrypt a file using a password:\n\n```bash\npython src/encryptf.py --encrypt --file /path/to/file.txt --password \"yourpassword\"\n```\n\n### Decrypting a File\n\nTo decrypt a file using a key file:\n\n```bash\npython src/encryptf.py --decrypt --file /path/to/file.txt --key /path/to/keyfile.key\n```\n\nTo decrypt a file using a password:\n\n```bash\npython src/encryptf.py --decrypt --file /path/to/file.txt --password \"yourpassword\"\n```\n\n### Encrypting or Decrypting Directories\n\nYou can recursively encrypt or decrypt all files in a directory using the `--directory` option:\n\n```bash\npython src/encryptf.py --encrypt --directory /path/to/directory --key /path/to/keyfile.key\n```\n\n### Security Notes\n\n- **Dynamic Salt**: Each encryption operation generates a random 16-byte salt. This ensures that even with the same password, encryption results are unique.\n- **Safety Features**: The script checks for unsafe directories like the home directory or root before proceeding.\n\n## Testing\n\nTo run unit tests and verify the script:\n\n```bash\npython -m unittest discover -s tests\n```\n\n## Project Structure\n\nFor those interested in the code:\n\n```bash\nproject-folder/\n├── src/\n│   ├── __init__.py       # Makes it a package\n│   ├── encryptf.py       # Main script for encryption and decryption\n├── tests/\n│   ├── test_encrypt_decrypt.py  # Unit tests for the script\n├── requirements.txt      # List of dependencies\n```\n\n## Contributions\n\nContributions are welcome! If you have ideas for improvements or new features, feel free to fork the repository, create a feature branch, and submit a pull request.\n\n## License\n\nThis script is licensed under the MIT License. See the `LICENSE` file for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthomason%2Fencrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmthomason%2Fencrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmthomason%2Fencrypt/lists"}