Overview
The PGP node's "Decrypt" operation allows you to decrypt data that was previously encrypted using PGP (Pretty Good Privacy). It supports both text and file decryption. This is useful in workflows where sensitive information needs to be securely transmitted or stored, and later decrypted for use within n8n. Common scenarios include:
- Decrypting files received via email or API before processing.
- Unsealing confidential messages for further automation steps.
- Handling secure document workflows.
Example:
You receive a .pgp-encrypted file as an email attachment. Use this node to decrypt the file and pass its contents to subsequent nodes for analysis or storage.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Type | options | Select whether you want to decrypt a "File" or a "String". |
| Text | string | The armored PGP-encrypted text to decrypt. Only shown if Type is "String". |
| Binary Property | string | The name of the binary property containing the encrypted file. Default: data. Shown if Type is "File". |
| Output Property | string | The name for the output binary property with the decrypted file. Default: decrypted. Shown if Type is "File". |
Output
If Type is "String":
- The output will be an array of objects with a field:
decrypted: Contains the decrypted plain text.
[ { "decrypted": "your decrypted message here" } ]- The output will be an array of objects with a field:
If Type is "File":
- The output will be an item with a binary property (default:
decrypted, or as specified in "Output Property") containing the decrypted file. - The binary property includes:
fileName: Original file name without.pgpextension (if present).- File content: The decrypted file data.
- No additional JSON fields are added except for the binary property.
Note: If decryption fails, and "Continue On Fail" is enabled, the output will contain an
errorfield with the error message.- The output will be an item with a binary property (default:
Dependencies
- External Service: Requires a valid PGP private key and passphrase, configured as n8n credentials (
pgpKey). - Node Package: Uses the
openpgplibrary for cryptographic operations. - n8n Configuration: No special environment variables required beyond the credential setup.
Troubleshooting
Common Issues:
- Invalid Key/Passphrase: If the provided PGP key or passphrase is incorrect, decryption will fail.
- Incorrect Input Type: Supplying a file when "String" is selected (or vice versa) will result in errors.
- Malformed Encrypted Data: If the input text or file is not a valid PGP-encrypted message, decryption will not succeed.
Error Messages:
"Error: ...": General decryption errors, often due to invalid keys, passphrases, or corrupted data.- Resolution: Double-check your PGP credentials and ensure the input data is correctly formatted.
"Cannot read property '...' of undefined": Likely caused by missing or misnamed binary properties.- Resolution: Ensure the "Binary Property" matches the actual property name in your input data.