wauth.core module¶
Cryptographic engine for encrypting and decrypting data using Fernet.
- class wauth.core.CryptoEngine(custom_key=None)[source]¶
Bases:
objectHandles encryption and decryption using Fernet (AES-128-CBC).
The encryption key is derived from a machine-specific identifier, meaning data encrypted on one machine can only be decrypted on that same machine.
- Parameters:
custom_key (str | None) – Optional custom encryption key string. If provided, it is hashed with SHA-256 to produce a deterministic 32-byte key. If
None, the key is derived from the machine identifier.
- decrypt(token)[source]¶
Decrypt a Fernet token back to raw bytes.
- Parameters:
token (str) – Base64-encoded Fernet token.
- Returns:
Decrypted plaintext as bytes.
- Raises:
DecryptionError – If the token is invalid, tampered, or encrypted with a different key.
- Return type: