A simple module for file encryption and decryption of the file
Project description
HarshCrypto
HarshCrypto is a Python library that provides simple and secure file encryption and decryption using the Fernet symmetric encryption scheme from the cryptography library. It supports individual files and directory
Features
- Encrypt individual files securely.
- Decrypt encrypted files.
- Process entire directories recursively.
- Ensures files are only encrypted or decrypted once.
- Lightweight and easy to integrate.
Installation
Install the package via pip:
pip install harshCrypto
Quick Start
Generating a Key
Before encrypting or decrypting files, generate an encryption key:
Copy code
from harshcrypto import generate_key
Generate a key and save it as key.key
generate_key()
This creates a key.key file in the current directory.
Loading the Key
Load the key when needed for encryption or decryption:
from harshcrypto import load_key
key = load_key("key.key")
Encrypting a File
Encrypt a single file using the loaded key:
from harshcrypto import encrypt_file, load_key
key = load_key("key.key")
encrypt_file("example.txt", key)
Decrypting a File
Decrypt a previously encrypted file:
from harshCrypto import decrypt_file, load_key
key = load_key("key.key")
decrypt_file("example.txt", key)
Encrypting or Decrypting an Entire Directory
Encrypt or decrypt all files in a directory recursively:
from harshCrypto import process_directory, load_key
key = load_key("key.key")
# Encrypt all files in the directory
process_directory("path/to/directory", key, operation="encrypt")
# Decrypt all files in the directory
process_directory("path/to/directory", key, operation="decrypt")
Requirements
- Python 3.6 or higher
- Dependencies :
cryptography
Install the required dependencies using pip:
pip install cryptography
Security Considerations
- Key Storage: Ensure the key.key file is stored securely. If lost, the encrypted files cannot be decrypted.
- Backup Files: Always backup your files before encryption in case of unforeseen issues.
- Encryption Scheme: Uses Fernet, which provides authenticated encryption (AES in CBC mode with PKCS7 padding and HMAC for authentication).
Contributing
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request.
- Fork the repository.
- Create a feature branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
If you encounter any issues or have questions, feel free to open an issue in the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file harshcrypto-1.0.0.tar.gz.
File metadata
- Download URL: harshcrypto-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae3d6850e3b04171fae7f4ca3e0d40cb0c85587188df07440191852872c37a92
|
|
| MD5 |
ce5b346964957afcf28ec9d639426112
|
|
| BLAKE2b-256 |
1586e7b6f6131b76ab64abb16269db20b5dd2cb9c6f08a9514cfb523ba6263b6
|
File details
Details for the file harshCrypto-1.0.0-py3-none-any.whl.
File metadata
- Download URL: harshCrypto-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e9bcfb81f2a07a78c51cee1c03674855b9cd4f17d2cb0ed573b0a9d49fc545f
|
|
| MD5 |
ee69d9b4565faf187373aa20a3a31cb8
|
|
| BLAKE2b-256 |
5718d94f5bb07e922e3f5830b0a79178a6be53200997b9c2dc60364851a92f07
|