Skip to main content

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.

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harshcrypto-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harshCrypto-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for harshcrypto-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ae3d6850e3b04171fae7f4ca3e0d40cb0c85587188df07440191852872c37a92
MD5 ce5b346964957afcf28ec9d639426112
BLAKE2b-256 1586e7b6f6131b76ab64abb16269db20b5dd2cb9c6f08a9514cfb523ba6263b6

See more details on using hashes here.

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

Hashes for harshCrypto-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e9bcfb81f2a07a78c51cee1c03674855b9cd4f17d2cb0ed573b0a9d49fc545f
MD5 ee69d9b4565faf187373aa20a3a31cb8
BLAKE2b-256 5718d94f5bb07e922e3f5830b0a79178a6be53200997b9c2dc60364851a92f07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page