Overview
This node provides encryption and decryption functionality using GPG (GNU Privacy Guard) keys. It supports two main operations: encrypting data and decrypting data. The data can be either a string or a file (binary data). This node is useful in scenarios where secure data transmission or storage is required, such as encrypting sensitive information before sending it over the internet or decrypting received encrypted files or messages.
Practical examples:
- Encrypting a text message before saving it to a database or sending it via email.
- Encrypting files like PDFs or images before uploading them to cloud storage.
- Decrypting received encrypted files or messages for further processing within an automation workflow.
Properties
Name | Meaning |
---|---|
Type | Choose whether the input data is a "File" (binary data) or a "String" (text data) to process. |
Text | The plain text string to encrypt or decrypt (shown only if Type is "String"). |
Binary Property | The name of the binary property containing the file data to encrypt or decrypt (default: "data", shown only if Type is "File"). |
Output Property | The name of the binary property where the output encrypted/decrypted file will be stored (shown only if Type is "File"). Defaults to "encrypted" for encryption and "decrypted" for decryption. |
Add Additional Properties | Boolean flag to add extra custom properties to the output JSON object (shown only if Type is "String"). |
Additional Properties | A JSON object with any additional data to include in the output when processing strings (shown only if Add Additional Properties is true and Type is "String"). |
Output
The node outputs JSON data structured differently depending on the operation and type:
For string inputs:
- On encryption:
{ encrypted: <encrypted_string> }
- On decryption:
{ decrypted: <decrypted_string> }
- If additional properties are added, they appear alongside the encrypted/decrypted field.
- On encryption:
For file inputs:
- The output is binary data stored in the specified output binary property.
- Encrypted files have
.gpg
extension and MIME typeapplication/pgp-encrypted
. - Decrypted files retain their original filename and binary format.
- The output JSON metadata wraps this binary data accordingly for n8n execution.
Dependencies
- Requires an API key credential that provides access to the GPG private/public key and passphrase.
- Uses the
openpgp
library internally for cryptographic operations. - No external service calls beyond the provided credentials are made.
- The node expects valid armored GPG keys and correct passphrases to function properly.
Troubleshooting
Common issues:
- Invalid or improperly formatted GPG keys will cause errors during encryption/decryption.
- Incorrect passphrase for the private key will prevent decryption.
- Missing or incorrect binary property names may lead to failures in reading input files.
- Trying to decrypt non-encrypted data or encrypt unsupported formats may cause errors.
Error messages and resolutions:
"Error: Could not read key"
: Check that the provided GPG key is correctly formatted and valid."Error: Incorrect passphrase"
: Verify the passphrase matches the private key."Binary data not found"
: Ensure the binary property name matches the input data's binary property.- General cryptographic errors usually indicate invalid input data or keys; verify all inputs carefully.