castlecraft_engineer.common.crypto
¶
castlecraft_engineer.common.crypto
¶
InvalidEncryptionFormat
¶
Bases: ValueError
Custom exception for invalid encryption format.
Source code in src/castlecraft_engineer/common/crypto.py
decrypt_data(encrypted_data, key)
¶
Decrypts data encrypted with AES-GCM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
encrypted_data
|
str
|
The base64 encoded string containing the nonce and ciphertext. |
required |
key
|
bytes
|
The AES decryption key (must be 16, 24, or 32 bytes). |
required |
Returns:
Type | Description |
---|---|
str
|
The decrypted string data. |
Source code in src/castlecraft_engineer/common/crypto.py
encrypt_data(data, key)
¶
Encrypts data using AES-GCM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
str
|
The string data to encrypt. |
required |
key
|
bytes
|
The AES encryption key (must be 16, 24, or 32 bytes). |
required |
Returns:
Type | Description |
---|---|
str
|
A base64 encoded string of the nonce prepended to the ciphertext and tag. |