dlt.common.libs.cryptography
generate_secret
def generate_secret() -> str
Generates a random url-safe secret with high entropy.
derive_encryption_key
def derive_encryption_key(secret: str, purpose: str) -> str
Derives a url-safe Fernet key from secret for purpose with HKDF-SHA256.
encrypt_text
def encrypt_text(key: str, text: str) -> str
Encrypts text with a Fernet key. Returns a url-safe token.
decrypt_text
def decrypt_text(key: str, token: str) -> str
Decrypts a Fernet token with key. Raises ValueError when the key does not match.
decode_private_key
def decode_private_key(private_key: str,
password: Optional[str] = None) -> bytes
Decode encrypted or unencrypted private key from string. Supported formats:
- base64 encoded DER
- plain-text or base64 encoded PEM