Overview
This node provides PGP (Pretty Good Privacy) encryption and decryption capabilities within an n8n workflow. It allows users to securely encrypt or decrypt data either as plain text strings or as binary files using a provided PGP key.
Common scenarios where this node is beneficial include:
- Encrypting sensitive information before storing or transmitting it.
- Decrypting received encrypted messages or files for further processing.
- Automating secure file handling workflows, such as encrypting backups or decrypting incoming confidential documents.
Practical examples:
- Encrypt a text message with a public PGP key before sending it via email.
- Decrypt an encrypted PDF file received from a partner system to extract its contents.
- Batch process multiple files by encrypting them with a shared PGP key for secure archival.
Properties
| Name | Meaning |
|---|---|
| Type | Choose the input data type: File (binary data) or String (plain text). |
| Text | The plain text string to encrypt or decrypt. Only shown if Type is "String". |
| Binary Property | The name of the binary property containing the file data to encrypt or decrypt. Only shown if Type is "File". Default is data. |
| Output Property | The name of the binary property where the output file will be stored after processing. Only shown if Type is "File". Defaults to "encrypted" when encrypting and "decrypted" when decrypting if left empty. |
Output
The node outputs JSON data structured as follows depending on the operation and input type:
For String type:
- When encrypting:
{ "encrypted": "<PGP encrypted armored string>" } - When decrypting:
{ "decrypted": "<Decrypted plain text string>" }
- When encrypting:
For File type:
- The output is binary data stored in the specified output binary property.
- When encrypting, the output file has
.pgpextension and MIME typeapplication/pgp-encrypted. - When decrypting, the output file retains the original filename without the
.pgpextension. - The binary data contains the encrypted or decrypted file content accordingly.
Dependencies
- Requires a valid PGP key credential with the private or public key and passphrase as applicable.
- Uses the
openpgplibrary for cryptographic operations. - The node expects proper configuration of credentials in n8n to access the PGP keys.
Troubleshooting
Common issues:
- Incorrect or missing PGP key credential will cause failures in encryption/decryption.
- Providing wrong passphrase for the private key during decryption will result in errors.
- Specifying a non-existent binary property name will cause the node to fail asserting binary data.
- Input data not matching the selected type (e.g., trying to decrypt a string when expecting a file) can cause unexpected errors.
Error messages and resolutions:
- "Failed to read PGP key" — Verify that the PGP key credential is correctly configured and contains a valid armored key.
- "Incorrect passphrase" — Check the passphrase used for the private key is correct.
- "Binary data not found" — Ensure the binary property name matches the actual input binary data property.
- "Message format invalid" — Confirm that the input data is properly formatted PGP encrypted data.
Enabling "Continue On Fail" allows the workflow to proceed even if some items fail, returning error details per item.