Skip to main content

Super lightweight, secure local file-based database encrypted with AES/Fernet + PBKDF2

Project description

Simple Crypt Dat

Super lightweight, secure local JSON file-based database encrypted with AES (Fernet) and derived keys using PBKDF2HMAC-SHA256. Perfect for desktop apps, Telegram bots, or lightweight scripts requiring password-protected data files.

Installation

Install using pip:

pip install simple-crypt-dat

Features

  • No Server Needed: Store data in a single local .dat file.
  • AES-128 in CBC mode + HMAC-SHA256: Handled via standard Cryptography Fernet.
  • PBKDF2 Key Derivation: Automatically derives keys using 100,000 iterations and a cryptographically secure random 16-byte salt saved directly inside the file header.
  • JSON Serializable: Store complex Python lists, dicts, strings, and numbers easily.
  • Password retry friendly: Raises custom InvalidPasswordError when decryption fails.

Quick Start

1. Save Encrypted Data

from simple_crypt_dat import EncryptedFileDB

# Initialize DB with the target file path
db = EncryptedFileDB("secrets.dat")

# Any JSON-serializable Python structure
secret_accounts = [
    {"user": "admin", "token": "abc123xyz"},
    {"user": "moderator", "token": "pqr456lmn"}
]

# Encrypt and save with a password
db.save(secret_accounts, password="MySuperSecretPassword")
print("Encrypted data saved successfully to secrets.dat!")

2. Load and Decrypt Data

from simple_crypt_dat import EncryptedFileDB, InvalidPasswordError

db = EncryptedFileDB("secrets.dat")

try:
    # Load and decrypt using the correct password
    data = db.load(password="MySuperSecretPassword")
    print("Decrypted Data:", data)
    
except InvalidPasswordError:
    print("Error: The password entered is incorrect!")
except FileNotFoundError:
    print("Error: Database file not found.")

License

MIT License.

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

simple_crypt_dat-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

simple_crypt_dat-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file simple_crypt_dat-1.0.0.tar.gz.

File metadata

  • Download URL: simple_crypt_dat-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for simple_crypt_dat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f9122c765ff6bde04d4aaae9ff1813ba0a99b0a1c583029e904bb9e699c08bc1
MD5 4ccdffb3d146ffb6a106a8ca542201e6
BLAKE2b-256 73643c1147ac374596f7ac11b5391dac339257f343e2a8e8f4e2a8019d13c246

See more details on using hashes here.

File details

Details for the file simple_crypt_dat-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_crypt_dat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aef0c86929dcfe8a5953e345d16e605a964401c100489bfa33530afe36c853ed
MD5 1ed002354bd4055a571096e505b1b8f5
BLAKE2b-256 fb66a5a7fe66aae60379bc000289b47788042e7a143b78d1382f3629abdab32a

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