Documentation Index
Fetch the complete documentation index at: https://ahen.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
You can use the cli to automatically generate encryption keys
Generate encryption keys
# you can generate a secure encryption key and salt using the cli
# or generate a secure encryption key and salt using the this example code
from skypydb.security import EncryptionManager
# Generate a secure encryption key
encryption_key = EncryptionManager.generate_key()
salt = EncryptionManager.generate_salt()
print(encryption_key) # don't show this key to anyone
print(salt) # don't show this salt to anyone
Save keys
after generating those keys you will need to save them in a .env.local file, here is an example of how you should write the file:ENCRYPTION_KEY=your_key
SALT_KEY=your_key
Encrypt you data
Skypydb will encrypt your data with you encryption key and salt key.import os
import skypydb
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv(".env.local")
# Load encryption key from environment
encryption_key = os.getenv("ENCRYPTION_KEY") # create a encryption key and make it available in .env file before using it, don't show this key to anyone
salt_key = os.getenv("SALT_KEY") # create a salt key and make it available in .env file before using it, don't show this salt to anyone
# transform salt key to bytes
if salt_key is None:
raise ValueError("SALT_KEY missing")
salt_bytes = salt_key.encode("utf-8")
# Create encrypted database
client = skypydb.ReactiveClient(
encryption_key=encryption_key,
salt=salt_bytes,
encrypted_fields=["message"] # Optional: encrypt only sensitive fields
)
# All operations work the same - encryption is transparent!
tables = client.get_or_create_table()
# if the tables already exists the programe get them instead
# Access your tables
success_table = tables["success"]
warning_table = tables["warning"]
error_table = tables["error"]
# Automatically encrypted
success_table.add(
component="AuthService",
action="login",
message="User logged in successfully", # only this field is encrypted if encrypted_fields is not None
user_id="user123"
)
# Data is automatically decrypted when retrieved
user_success_logs = success_table.search(
user_id="user123"
)
if not user_success_logs:
print("No results found.")
else:
for user_success_log in user_success_logs:
print(user_success_log)