Metadata-Version: 2.4
Name: simple-crypt-dat
Version: 1.0.0
Summary: Super lightweight, secure local file-based database encrypted with AES/Fernet + PBKDF2
Author-email: CryptDB Developer <developer@tenmiencuaban.com>
Keywords: crypt,encryption,database,nosql,fernet,aes,pbkdf2,file-database
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Database
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=3.0.0
Dynamic: license-file

# 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:

```bash
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

```python
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

```python
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.
