Overview
This node provides PGP (Pretty Good Privacy) encryption and decryption capabilities within n8n workflows. It supports processing both text strings and binary files, allowing users to securely encrypt or decrypt data using PGP keys.
Common scenarios where this node is beneficial include:
- Encrypting sensitive text data before sending it over insecure channels.
- Decrypting received encrypted files or messages for further processing.
- Automating secure file handling workflows that require PGP encryption/decryption.
Practical examples:
- Encrypt a confidential message string before emailing it.
- Decrypt an incoming encrypted document stored as binary data in the workflow.
- Securely exchange files between systems by encrypting them with PGP keys.
Properties
| Name | Meaning |
|---|---|
| Type | Choose whether the input data is a "File" (binary data) or a "String" (text). |
| Text | The plaintext string to encrypt or the encrypted string to decrypt (shown if Type=String). |
| Binary Property | The name of the binary property containing the file data to encrypt or decrypt (shown if Type=File). Default is "data". |
| Output Property | The name of the binary property where the output file will be saved (shown if Type=File). If empty, defaults to "encrypted" for encryption and "decrypted" for decryption. |
Output
The node outputs JSON data structured as follows depending on the operation and type:
For String type:
- On encryption:
{ "encrypted": "<PGP encrypted armored string>" } - On decryption:
{ "decrypted": "<Decrypted plaintext string>" }
- On encryption:
For File type:
- The output is binary data attached to the specified output binary property.
- Encrypted files have
.pgpextension and MIME typeapplication/pgp-encrypted. - Decrypted files retain the original filename (removing
.pgpextension if present). - 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 holding the PGP keys and passphrases.
Troubleshooting
Common issues:
- Incorrect or missing PGP keys or passphrases will cause encryption/decryption failures.
- Providing invalid armored PGP messages or corrupted binary data can lead to errors.
- Mismatched input types (e.g., trying to decrypt a non-PGP file) may cause exceptions.
Error messages and resolutions:
- Errors related to key reading or decryption usually indicate wrong keys or passphrases; verify credentials.
- "assertBinaryData" errors mean the specified binary property does not exist or is empty; check input data.
- If the node fails but "Continue On Fail" is enabled, error details are returned in the output JSON under an
errorfield.