🟦 Mores-Encryption
A Lightweight, Production-Ready Encryption Library for Python
Mores-Encryption is a clean, minimal, plug-and-play encryption library designed to make securing sensitive data effortless. Built on top of industry-standard AES-128 (Fernet), it provides simple helpers for:
✔ Encrypting & decrypting strings
✔ Deterministic hashing (searchable encryption)
✔ Secure JSON encryption
✔ Automatic key handling
✔ URL-safe output
Perfect for securing PII, emails, IDs, session tokens, API keys, medical data, or database fields across any Python backend.
Mores-Encryption removes the repetitive boilerplate and cryptographic complexity so you can focus on building — not configuring.
🔒 Features
🔐 Simple AES-128 Encryption
One-line methods: encrypt() and decrypt()
🔎 Deterministic Hashing for Search
Search encrypted fields using hash()
(same input + same salt = same output)
📦 JSON Encryption Support
Encrypt entire dictionaries with encrypt_json() and decrypt_json()
⚙️ Automatic Key Management
Loads ENCRYPTION_KEY from environment or generates a secure key if missing
🪶 Lightweight & Zero-Config
Only one dependency: cryptography
🌐 Works Everywhere
FastAPI, Django, Flask, LangChain, Redis, MongoDB, SQL, background jobs — plug it into anything.
📦 Installation
pip install mores-encryption
⚙️ Setup
Generate a secure encryption key:
python -c "from cryptography.fernet import Fernet; print('ENCRYPTION_KEY=' + Fernet.generate_key().decode())"
Save it in .env:
ENCRYPTION_KEY=your_generated_key_here
🚀 Usage
1. Encrypt & Decrypt
from mores_encryption.encryption import encryption_service
secret = "My Secret Data"
encrypted = encryption_service.encrypt(secret)
print("Encrypted:", encrypted)
decrypted = encryption_service.decrypt(encrypted)
print("Decrypted:", decrypted)
2. Deterministic Hashing
Perfect for searching encrypted emails, IDs, etc.
email = "user@example.com"
salt = "my_static_salt"
hashed = encryption_service.hash(email, salt)
print(hashed)
3. JSON Encryption
data = {"card": "1234-5678-9012-3456"}
encrypted = encryption_service.encrypt_json(data)
print(encrypted)
decrypted = encryption_service.decrypt_json(encrypted)
print(decrypted)
🧪 Why Use Mores-Encryption?
Because encryption shouldn't be painful.
Most developers struggle with cryptographic setup — salts, key formats, byte handling, serialization, JSON encoding, PBKDF2 — and end up copying the same boilerplate between projects.
Mores-Encryption gives you:
- Clean API
- Strong security defaults
- Minimal code surface
- Reusable across all your projects
- Faster development + fewer mistakes
Configuration
The library uses environment variables for configuration. You can set these in your .env file or export them in your shell.
| Variable | Description | Required | Default |
|---|---|---|---|
ENCRYPTION_KEY |
Base64-encoded 32-byte Fernet key. | No (Auto-generated if missing) | N/A |
Key & Salt Generation
Run these commands in your terminal to generate secure values for your .env file:
Generate Encryption Key:
python -c "from cryptography.fernet import Fernet; print('ENCRYPTION_KEY=' + Fernet.generate_key().decode())"
Generate Salt (for deterministic hashing):
python -c "import secrets; print('EMAIL_SALT=' + secrets.token_urlsafe(16))"
Step-by-Step Setup:
- Run the commands above.
- Copy the output (e.g.,
ENCRYPTION_KEY=...). - Paste it into your
.envfile in the project root.
Note: For a complete integration example, refer to
integration.ipynb(if included in the examples).
Security Implementation Details
- Encryption:
cryptography.fernet.Fernet(AES-128 CBC with PKCS7 padding, HMAC-SHA256 for integrity). - Hashing: PBKDF2HMAC-SHA256 with configurable iterations (default: 200,000) and a 32-byte output length.
- Encoding: All outputs are URL-safe Base64 encoded strings.
📚 Documentation & Source Code
GitHub: https://github.com/HATAKEkakshi/mores-encryption
License
MIT License
Metadata
Release files for mores-encryption 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mores_encryption-0.1.5.tar.gz | 8.6 kB | Without provenance | Details for mores_encryption-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mores_encryption-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for mores_encryption-0.1.5-py3-none-any.whl |
Total release size: 16.1 kB
Release files / mores_encryption-0.1.5.tar.gz
| Download URL | mores_encryption-0.1.5.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18addc7bf6d414f17777d98b638bd774b6c0cedfaca95ecb09407f09233add1e
|
|
BLAKE2b-256 checksum How to use checksums |
0c480886739c47e0d3f584005d307d54287f59c6aed059cc36ff10b0a4cc0ca5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / mores_encryption-0.1.5-py3-none-any.whl
| Download URL | mores_encryption-0.1.5-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e88a47a11d71da1f9a9ff845197ec20f887f30824b94662147daac99b3a199e2
|
|
BLAKE2b-256 checksum How to use checksums |
e78c39b66ae0ac3e54fa7ce0b3b711417db52ccb69249d90b4cefdcf7d37c79a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for mores-encryption 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.