BlocksTokens & Crypto
Encrypt String
Securely lock sensitive data so it can only be read with a secret key.
The Encrypt String block uses advanced encryption to turn readable text into a scrambled string that can only be unlocked with the correct Secret. This is essential for storing sensitive information like external API keys or personal data.
Core Concept: The Digital Vault
Think of encryption like placing a note inside a high-security vault.
- The Secret is the physical key.
- The Initialization Vector (IV) is like a unique starting position for the lock's gears, ensuring that even if you store the same note twice, the resulting vault looks different from the outside.
Secret Management
If you lose your Secret, any data encrypted with it becomes permanently unreadable.
Configuration
| Field | Required | Description |
|---|---|---|
| Secret | ✅ | The project secret used for encryption. |
| Input String | ✅ | The text you want to encrypt. |
| Encryption Algorithm | ✅ | Select the method: AES-256 (recommended) or AES-128. |
| Initialization Vector (IV) | — | Optional 32-character hex string. If left empty, a secure random IV is generated automatically. |
| Encoding Type | ✅ | How to format the final encrypted text: base64 or hex. |
| Encrypted Variable | ✅ | The name of the variable that will store the encrypted result. |
Error Handling
SECRET_MISSING— Triggered when no secret is provided.FIELD_MISSING— Triggered if the input, algorithm, or encoding fields are empty.SECRET_RETRIEVE_ERROR— Triggered if the selected secret cannot be loaded.ENCRYPTION_INVALID_KEY_LENGTH— Triggered if your secret isn't the correct length for the chosen algorithm.ENCRYPTION_INVALID_ALGORITHM— Triggered if the specified algorithm is not supported.ENCRYPTION_INPUT_TOO_LARGE— Triggered if the input data is too large to encrypt.ENCRYPTION_FAILED— Triggered for general encryption failures.
Example: Storing a Third-Party API Key
- Secret: Select your
STORAGE_ENCRYPTION_KEY. - Input String: Enter the sensitive key, e.g.,
sk_live_51M.... - Encryption Algorithm: Select
AES-256. - Encoding Type: Select
base64. - Encrypted Variable: Enter
encrypted_api_key. - Result: The variable
{encrypted_api_key}now contains a scrambled string that you can safely save to your database.
