Overview
This node provides string encoding and decoding functionality using the StrEncoderKit library. It allows users to encode or decode strings with customizable character sets, optional compression, and encryption features. This is useful for scenarios where you need to securely transform text data, such as obfuscating sensitive information, compressing data for storage or transmission, or applying custom encoding schemes.
Practical examples include:
- Encoding a message before sending it over an insecure channel.
- Decoding received encoded data back to its original form.
- Compressing and encrypting configuration strings or tokens.
- Adding custom prefixes or suffixes to encoded strings for identification or formatting.
Properties
| Name | Meaning |
|---|---|
| 輸入字串 (input) | The string to be encoded or decoded. |
| 編碼/解碼 (actionType) | Choose whether to perform encoding ("編碼") or decoding ("解碼"). |
| 字元集合 (chars) | Character set used to define which characters are available during encoding. Default is "日月火水木金土". |
| 字串前綴 (prefix) | A prefix string added before the encoded output. |
| 字串後綴 (suffix) | A suffix string added after the encoded output. |
| 加密 (encrypt) | Enable or disable encryption feature (boolean). Default is enabled (true). |
| 加密金鑰 (key) | Encryption key used for encoding/decoding. Defaults to "strencoderkit" if empty. |
| 壓縮 (compress) | Enable or disable compression feature (boolean). Default is enabled (true). |
| 拋出錯誤 (throwError) | When decoding, choose whether to throw an error on failure (true) or silently handle it (false). Only applicable for decoding operation. Default is false. |
Output
The node outputs a JSON object with a single field:
result: The resulting string after encoding or decoding. This will be the transformed string according to the selected options (encoding/decoding, compression, encryption, prefix/suffix).
No binary data output is produced by this node.
Example output JSON:
{
"result": "encoded_or_decoded_string_here"
}
Dependencies
- Requires the external library StrEncoderKit for encoding and decoding operations.
- No special environment variables or API keys are needed beyond providing an optional encryption key in the node parameters.
Troubleshooting
Common issues:
- Providing an invalid encryption key or mismatched key during decoding may cause errors or incorrect results.
- Using unsupported characters outside the defined character set might lead to unexpected behavior.
- If decoding fails and
throwErroris set to false, the node will attempt silent decoding; otherwise, it will throw an error.
Error messages:
- Errors thrown during encoding/decoding are wrapped as node operation errors with context about the item index.
- To resolve errors, verify that the input string matches the expected format, the correct encryption key is used, and the character set includes all necessary characters.
Links and References
- StrEncoderKit GitHub Repository (replace with actual URL if known)
- n8n Documentation on Creating Custom Nodes