Development

This commit is contained in:
Matthew Grotke 2026-06-07 00:50:49 -04:00
parent 5071f06624
commit a3bab5ff1f
5 changed files with 53 additions and 50 deletions

View file

@ -7,3 +7,16 @@ def is_production():
def is_pro():
return bool(os.environ.get('LICENSE', '').strip())
def get_credentials_key():
"""Return a Fernet-compatible key derived from the CREDENTIALS_KEY environment variable,
or None if not set. SHA-256 hashes the raw string to produce 32 bytes, which are then
URL-safe base64-encoded as required by Fernet."""
import base64
import hashlib
key_str = os.environ.get('CREDENTIALS_KEY', '')
if not key_str:
return None
raw = hashlib.sha256(key_str.encode()).digest()
return base64.urlsafe_b64encode(raw)