Overview
This n8n node provides PGP (Pretty Good Privacy) encryption and decryption capabilities for both text and file data. It allows users to securely encrypt or decrypt strings or binary files using a provided PGP key. This is useful in workflows where sensitive information needs to be protected, such as sending encrypted emails, storing confidential documents, or integrating with systems that require PGP-encrypted data.
Practical examples:
- Encrypting uploaded files before saving them to cloud storage.
- Decrypting incoming PGP-protected email attachments.
- Securing API payloads by encrypting string data before transmission.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Type | options | Select whether to process a "File" (binary data) or a "String" (text data). |
| Text | string | The text to encrypt or decrypt. Only shown when "Type" is set to "String". |
| Binary Property | string | The name of the binary property containing the file to encrypt/decrypt. Default: "data". Only shown when "Type" is "File". |
| Output Property | string | The name of the output binary property for the result. Default is empty. Only shown when "Type" is "File". |
Output
For String Type:
- When encrypting:
[ { "encrypted": "<PGP armored encrypted string>" } ] - When decrypting:
[ { "decrypted": "<Decrypted plain text string>" } ]
- When encrypting:
For File Type (Binary Data):
- The output will contain a new or updated binary property (as specified in "Output Property") with:
- The encrypted or decrypted file data.
- Metadata fields such as
fileName,fileExtension(set to "pgp" for encrypted files), andmimeType(set to "application/pgp-encrypted" for encrypted files).
- The structure of the JSON output remains unchanged except for the addition or update of the specified binary property.
- The output will contain a new or updated binary property (as specified in "Output Property") with:
Dependencies
- External Services: Requires a valid PGP key (public key for encryption, private key and passphrase for decryption).
- Credentials: The node requires an n8n credential named
pgpKeycontaining the necessary key(s) and, for decryption, the passphrase. - Environment: No special environment variables are required beyond standard n8n configuration.
Troubleshooting
Common Issues:
- Invalid Key Format: If the provided PGP key is not properly formatted, encryption or decryption will fail.
- Missing Passphrase: For decryption, if the passphrase is missing or incorrect, the operation will fail.
- Incorrect Property Names: If the "Binary Property" does not match the actual binary property in the input, the node will throw an error about missing binary data.
- File Extension Handling: When decrypting, the node attempts to remove the
.pgpextension from the output file name. If the original file name is missing or malformed, this may not work as expected.
Error Messages:
"error": "<error message>"— If an error occurs and "Continue On Fail" is enabled, the error message will be included in the output under anerrorfield.- Errors related to missing or invalid keys, passphrases, or binary data will be thrown and can be resolved by checking the corresponding input values.