Overview
This node provides PGP (Pretty Good Privacy) encryption and decryption capabilities within n8n workflows. It allows users to securely encrypt or decrypt either text strings or binary files using a provided PGP key. This is useful for scenarios where sensitive data needs to be protected before storage, transmission, or further processing, such as encrypting confidential documents or decrypting received encrypted messages.
Practical examples include:
- Encrypting a text message before sending it via email.
- Encrypting files like PDFs or images before uploading them to cloud storage.
- Decrypting received encrypted files or messages to access their contents within an automated workflow.
Properties
| Name | Meaning |
|---|---|
| Type | Choose whether the input data is a "File" (binary data) or a "String" (text data). |
| Text | The plain text string to encrypt or decrypt. Visible only when Type is "String". |
| Binary Property | The name of the binary property containing the file data to encrypt or decrypt. Visible only when Type is "File". Default is "data". |
| Output Property | The name of the binary property where the encrypted or decrypted file will be stored. Visible only when Type is "File". If empty, defaults to "encrypted" for encryption or "decrypted" for decryption. |
Output
The node outputs JSON data with the following structure depending on the operation and type:
For string encryption:
[ { "encrypted": "<PGP encrypted armored string>" } ]For string decryption:
[ { "decrypted": "<Decrypted plain text string>" } ]For file encryption/decryption:
The output item contains a binary property (named by the user or defaulted) holding the encrypted or decrypted file data. The binary metadata includes:fileName: Original filename appended with.pgpfor encrypted files, or original filename without.pgpextension for decrypted files.fileExtension: Set to"pgp"for encrypted files.mimeType: Set to"application/pgp-encrypted"for encrypted files.
The binary data is properly prepared for downstream nodes to consume.
Dependencies
- Requires a valid PGP key credential with the private or public key and optionally a passphrase.
- Uses the
openpgplibrary for cryptographic operations. - The node expects the PGP key credential to be configured in n8n credentials securely.
Troubleshooting
Common issues:
- Incorrect or malformed PGP keys can cause encryption or decryption failures.
- Missing or wrong passphrase for private keys during decryption will result in errors.
- Specifying a non-existent binary property name will cause the node to fail asserting binary data.
- Trying to decrypt data that is not properly PGP encrypted will throw errors.
Error messages and resolutions:
- "Error reading PGP key" — Verify the PGP key credential is correctly set and formatted.
- "Incorrect passphrase" — Ensure the passphrase matches the private key's passphrase.
- "Binary property not found" — Check that the binary property name matches the input data's binary field.
- "Decryption failed" — Confirm the input data is a valid PGP encrypted message/file.
Enabling "Continue On Fail" allows the workflow to proceed even if some items fail encryption/decryption, returning error details per item.