Secure File Encryption Library
Project description
securefilecrypt — Simple AES-GCM File Encryption
SecureFileCrypt is a Python utility for encrypting and decrypting files using AES-256-GCM with password-based key derivation (PBKDF2-HMAC-SHA256).
It is designed for ease of use while providing strong, modern encryption with authentication to ensure data confidentiality and integrity.
Features
- AES-256 in Galois/Counter Mode (GCM) for authenticated encryption
- Password-based key derivation using PBKDF2-HMAC-SHA256 with configurable iterations
- Random salt and nonce generated for each encryption
- Automatic salt length derived from password characteristics
- Simple file-based workflow: encrypt and decrypt with one function call
- Compatible across Python 3.6+ on Windows, Linux, and macOS
Security Design
- Encryption algorithm: AES-256-GCM (confidentiality + authentication)
- Key derivation: PBKDF2-HMAC-SHA256, 100,000 iterations
- Salt: Random per file, length based on password contents
- Nonce: 12 bytes random per encryption
- Password requirements: At least 12 base36 characters (
0-9a-z)
Installation
pip install securefilecrypt
Quick Start
Encrypt a file
from securefilecrypt import EncryptFile
status, message = EncryptFile("secret.txt", "secret.enc", "mypassword123abc")
if not status:
print("Error:", message)
else:
print("File encrypted successfully!")
Decrypt a file
from securefilecrypt import DecryptFile
status, message = DecryptFile("secret.enc", "secret_decrypted.txt", "mypassword123abc")
if not status:
print("Error:", message)
else:
print("File decrypted successfully!")
Command line tool
On the command line the library can be called with the following arguments:
Usage: sfcrypt <input_file> <output_file> (--encrypt|--decrypt) (--pw:<password>|--ev:<envvar>)
<input_filename> : Input file for encryption or decryption
<output_filename> : Encrypted / decrypted file to produce
--encrypt : Encryption mode
--decrypt : Decryption mode
--pw:<password> : Password for encryption/decription
--ev:<envvar> : Get password for encryption / decryption from an environment variable
API Reference
EncryptData(input_file, password)
Encrypts input_file using AES-256-GCM with provided password.
Returns:
- `status' (bool): True if successful, False something went wrong
message(str): Error message in case of error, otherwise emptydata(bytes): Encrypted bytes
DecryptData(input_file, password)
Decrypts input_file using AES-256-GCM with provided password.
Returns:
- `status' (bool): True if successful, False something went wrong
message(str): Error message in case of error, otherwise emptydata(bytes): Decrypted bytes
EncryptFile(input_file, output_file, password)
Encrypts input_file into output_file using AES-256-GCM with provided password.
Returns:
- `status' (bool): True if successful, False something went wrong
message(str): Error message in case of error, otherwise empty
DecryptFile(input_file, output_file, password)
Decrypts input_file into output_file using AES-256-GCM with provided password.
Returns:
- `status' (bool): True if successful, False something went wrong
message(str): Error message in case of error, otherwise empty
Security Notes
- Always use a strong password (long, random, mix of letters/numbers).
- Store your password securely — if lost, data cannot be recovered.
- PBKDF2 is secure, but for higher resistance to GPU cracking, consider upgrading to Argon2id in the future.
License
MIT License — do anything with it, but no warranty.
Changelog
See the full changelog here.
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
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 securefilecrypt-0.1.7.tar.gz.
File metadata
- Download URL: securefilecrypt-0.1.7.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5108cd606900754a73229e324e886c5354ccdc7824f17004be8779be5f387fef
|
|
| MD5 |
5b801f166468285a443bf553dc8de99e
|
|
| BLAKE2b-256 |
41405b8fd82f1d363e550797ab954f3c4ddeb3e4dd7ddab64af2b3cec447b336
|
File details
Details for the file securefilecrypt-0.1.7-py3-none-any.whl.
File metadata
- Download URL: securefilecrypt-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed3bf996655747a692ed2699a3aec8d842d5755d9fc632d6644de2c0fbee800
|
|
| MD5 |
02d4909ce8314bdbc5943007e2b08fa8
|
|
| BLAKE2b-256 |
1bff69beca2a80b0ead77e5e463f20ff49fd5ae9f8e402934956829225a956d3
|