Overview
The PGP node provides encryption and decryption capabilities using the PGP (Pretty Good Privacy) standard. In the "Encrypt" operation, it allows users to encrypt either plain text or binary file data with a provided public key. This is useful for securely transmitting sensitive information, such as confidential documents or messages, ensuring that only intended recipients can decrypt and access the content.
Common scenarios:
- Encrypting files before sending them via email or uploading to cloud storage.
- Securing API secrets or credentials in automated workflows.
- Protecting sensitive user data within n8n automations.
Practical example:
You could use this node to encrypt a PDF report before emailing it to a client, ensuring only the client with the correct private key can open the file.
Properties
| Display Name | Type | Meaning |
|---|---|---|
| Type | options | Select whether to encrypt a "File" (binary data) or a "String" (plain text). |
| Text | string | The plain text to encrypt. Only shown if Type is "String". |
| Binary Property | string | The name of the input binary property containing the file to encrypt. Default: data. Only shown if Type is "File". |
| Output Property | string | The name of the output binary property where the encrypted file will be stored. Default: encrypted. Only shown if Type is "File". |
Output
For Type: String
- The output will be an array of objects with the following structure:
[ { "encrypted": "<PGP armored encrypted string>" } ]- encrypted: Contains the PGP-encrypted version of the input text.
For Type: File
- The output will be the original item with an additional binary property (default:
encrypted), containing:- The encrypted file data in binary format.
- Metadata fields:
- fileName: Original filename with
.pgpextension appended. - fileExtension: Always set to
pgp. - mimeType: Set to
application/pgp-encrypted.
- fileName: Original filename with
Note: If you specify a custom Output Property, the encrypted file will be available under that property name.
Dependencies
- External Service: Requires a valid PGP public key (provided via n8n credentials named
pgpKey). - n8n Configuration: No special environment variables required, but the
openpgplibrary is used internally.
Troubleshooting
Common issues:
- Missing or invalid PGP key: If the provided PGP key is missing or malformed, encryption will fail.
- Incorrect property names: If the specified Binary Property does not exist on the input item, the node will throw an error.
- Output Property conflicts: If the Output Property name already exists, it may overwrite existing data.
Error messages:
"Cannot read properties of undefined": Likely due to an incorrect Binary Property name."Error: Invalid armored text": The provided PGP key or message is not correctly formatted."No such file or directory": The referenced binary data is missing from the input.
How to resolve:
- Double-check the PGP key format and ensure it's correctly entered in the credentials.
- Verify that the Binary Property matches the property name of your input file.
- Ensure all required fields are filled and match the expected types.