Symmetric encryption and descryption (ByteDarkLock).
Project description
ByteDarkLock (BDL)
ByteDarkLock is a Python module for advanced symmetric encryption and script obfuscation, designed to protect your logic and data easily.
Main Features
-
Symmetric encryption with AES-256 (CFB mode) and Fernet (AES-128 + HMAC-SHA256).
-
Optional HMAC authentication to detect tampering in AES.
-
Key expiration (
ttl) and scheduled unlock (unlock_at). -
One-time decryption (
decrypt_once) to prevent replay attacks. -
Python script obfuscation:
- Keeps
importandfromstatements intact. - Removes docstrings and comments.
- Renames internal identifiers.
- Encodes literals in Base64.
- Packages into
exec(base64...)for maximum opacity. - Option to automatically compile to bytecode (
.pyc) and remove the obfuscated.py.
- Keeps
Requirements
Dependencies are listed in requirements.py (or install manually):
cryptography>=3.4.7
Pillow>=8.1.0
Quick installation with pip:
pip install cryptography Pillow
Quick Start Guide
from BDL.ByteDarkLock import ByteDarkLock
# Initialize
bdl = ByteDarkLock()
# 1. Generate a Fernet key with a TTL of 3600s
meta = bdl.generate_key(
key_id="my_key",
mode="fernet",
ttl=3600
)
# 2. Encrypt and decrypt
token = bdl.encrypt("Hello World", "my_key")
print("Encrypted:", token)
plain = bdl.decrypt(token, "my_key")
print("Decrypted:", plain)
# 3. One-time decryption
bdl.decrypt_once(token, "my_key") # works once
# bdl.decrypt_once(token, "my_key") # now fails
API Reference
Class ByteDarkLock
generate_key(key_id, mode='fernet', use_hmac=False, ttl=None, unlock_at=None) -> dict
Generates and stores a key.
- key_id (
str): Unique identifier. - mode (
'fernet'|'aes'): Algorithm. - use_hmac (
bool): AES only. - ttl (
int): Lifetime in seconds. - unlock_at (
datetime|str): Unlock date/time.
Returns metadata with key, expires_at, created_at, etc.
encrypt(data, key_id) -> str
Encrypts data with the key key_id.
decrypt(token, key_id) -> str
Decrypts token with the key key_id.
decrypt_once(token, key_id) -> str
Like decrypt, but allows only one use.
timed_decrypt(token, key_id) -> str
Alias for decrypt (for future time-lock feature).
Contributions
- Fork the repository.
- Create a branch (
git checkout -b feature/new-function). - Make your changes and commit (
git commit -m 'Add xyz'). - Submit a pull request.
License
This project is under the [MIT License].
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 bytedarklock_bdl-1.0.1.tar.gz.
File metadata
- Download URL: bytedarklock_bdl-1.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27dcbf221d52ac44bfe1f109c2f55a3cf690e575c34ada86242fb1e954a84b2d
|
|
| MD5 |
f656730393dc81e01124c7f6529555c6
|
|
| BLAKE2b-256 |
72980ff4a856a80e56bc15797a9a8ac2542199f5d0c7a560780f226f8ac75064
|
File details
Details for the file bytedarklock_bdl-1.0.1-py3-none-any.whl.
File metadata
- Download URL: bytedarklock_bdl-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17a4d084f1da349d3e0dde6b1f26dac71df884c7271158c426526c65b6c730c1
|
|
| MD5 |
ee61b771ffd58df033b7395e54af36ca
|
|
| BLAKE2b-256 |
56b009405a6918a2b843c7e8f03be18f093b71ea8cc405578bbffc39575d578c
|