Data Encryption/Decryption Service Using XOR and Base64 - n8n Workflow

Use this robust n8n workflow template to securely encrypt and decrypt sensitive data within your automation pipelines using XOR logic and Base64 encoding. Ideal for secure data handling via a dedicated n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Technical Users and Developers: Individuals needing custom security layers for data passed between different n8n workflows or systems.
Security-Conscious Automators: Users looking to handle sensitive keys or payloads securely within their n8n environment.


  • n8n Node Developers: Those building modular solutions who require a dedicated encryption service called via the n8n Execute Workflow trigger.

Overview

Security often requires custom solutions, especially when dealing with proprietary or sensitive data in automation pipelines. This n8n workflow provides a dedicated, reusable service for XOR encryption and decryption, augmented with Base64 encoding to handle binary data safely across JSON payloads.

Instead of building complex crypto logic into every automation, you can call this modular n8n template using the 'Execute Workflow' n8n node. This approach centralizes sensitive logic, making your main n8n workflow cleaner and easier to maintain. This specific n8n workflow leverages JavaScript code nodes to perform the cryptographic operations, ensuring a strong, consistent implementation every time it is activated by the n8n trigger.

How it Works

This n8n workflow operates entirely as a sub-routine, initiated by an external n8n node calling its internal trigger.


  1. Workflow Execution Trigger: The process begins when the When Executed by Another Workflow n8n trigger receives a payload containing three critical fields: action-type (either 'encrypt' or 'decrypt'), key (the XOR encryption key), and data (the payload to be processed).

  2. Conditional Routing (If n8n node): An If n8n node evaluates the action-type field. If the value strictly equals 'encrypt', the flow proceeds down the true path.

  3. Encryption Path (Code n8n node): If 'encrypt' is detected, the encrypt Code n8n node executes. This node uses JavaScript to perform XOR encryption on the input data using the provided key. Crucially, the resulting encrypted string is then encoded into Base64 for safe transfer as a standard text string within any subsequent n8n node.

  4. Decryption Path (Code n8n node): If the action-type is anything other than 'encrypt' (implicitly 'decrypt' in a well-structured call), the flow proceeds down the false path. The decrypt Code n8n node executes. It first decodes the Base64 input and then applies the XOR decryption using the provided key, returning the original, plaintext data to the calling n8n workflow.

Installation Guide

To utilize this security-focused n8n template, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and import it into your n8n instance via the Workflows section ('New' -> 'Import from JSON').

  2. Activate the n8n Workflow: Ensure the workflow is active. Since it uses the 'Execute Workflow' n8n trigger, it will only run when explicitly called by another n8n workflow, acting as an internal API service.

  3. Integrate Credentials (N/A): This specific n8n node structure does not require external credentials, as all encryption logic is handled internally via JavaScript.

  4. Call from Another n8n Workflow: In your main automation, use the Execute Workflow n8n node. Configure this n8n node to point to this Encryption/Decryption service and pass the necessary parameters: action-type, key, and data in the input mapping.

Node Details

When Executed by Another Workflow (n8n Trigger):
Function: Serves as the callable n8n trigger, allowing this modular n8n workflow to be run by other processes.
Key Configuration: Expects workflow inputs for action-type, key, and data.
If (n8n Node):
Function: Routes the execution path based on whether the input requires encryption or decryption.
Key Configuration: Checks if {{ $json['action-type'] }} equals 'encrypt'.
encrypt (Code n8n Node):
Function: Performs XOR encryption followed by Base64 encoding. This custom n8n node securely processes the payload.
Key Configuration: Contains a custom JavaScript function xorEncrypt that reads the data and key from the incoming payload and returns the Base64-encoded encrypted result.
decrypt (Code n8n Node):
Function: Performs Base64 decoding followed by XOR decryption. This powerful n8n node reverses the cryptographic process.
Key Configuration: Contains a custom JavaScript function xorDecrypt that reads the encrypted Base64 data and the shared key to return the original plaintext data.

Related n8n Workflows

Free

Nodes: 3 Nodes
Updated: December 26 2025
View all
Created by
Tenkay
Tenkay

I'm a software developer with over 11 years of experience building systems across various stacks. I'm now applying that expertise to create practical and scalable workflow automations with n8n — focusing on clean logic, real-world use cases, and reusability. Always open to learning, sharing, and collaborating.

Featured*