N
n8n Store
Workflow Market
simple-encryption

simple-encryption

by tenkay0 views

描述

分类

⚙️ Automation

使用的节点

n8n-nodes-base.ifn8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.executeWorkflowTrigger
价格免费
浏览量0
最后更新11/28/2025
workflow.json
{
  "id": "fElANcOcJejintLK",
  "meta": {
    "instanceId": "b502e5a8bc6c091b48560caa78bb54b47e56d5b7f2538880db0015950174c8b7",
    "templateCredsSetupCompleted": true
  },
  "name": "simple-encryption",
  "tags": [],
  "nodes": [
    {
      "id": "61c0e04b-bbac-4c1f-8dee-d2e8096cecc9",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -140,
        20
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "action-type"
            },
            {
              "name": "key"
            },
            {
              "name": "data"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "29fec805-be45-40bf-a7a5-52dcdc6a4e9e",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        80,
        20
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8f844b57-5893-44f8-a1c8-de653bfbac9e",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['action-type'] }}",
              "rightValue": "encrypt"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9c293a9b-7d52-4d97-a0b5-578e9f228b89",
      "name": "encrypt",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        -80
      ],
      "parameters": {
        "jsCode": "const message =$input.first().json.data || \"No Data\";\nconst key = $input.first().json.key;\n\nfunction xorEncrypt(text, key) {\n  let encrypted = \"\";\n  for (let i = 0; i < text.length; i++) {\n    const charCode = text.charCodeAt(i) ^ key.charCodeAt(i % key.length);\n    encrypted += String.fromCharCode(charCode);\n  }\n  return Buffer.from(encrypted).toString('base64'); \n}\n\nreturn [\n  {\n    json: {\n      encrypted: xorEncrypt(message, key)\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9376e4af-0923-404d-a596-8090cc0f9c8f",
      "name": "decrypt",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        120
      ],
      "parameters": {
        "jsCode": "const encrypted = $input.first().json.data;\nconst key = $input.first().json.key; // Must be the same key used to encrypt\n\nfunction xorDecrypt(base64Text, key) {\n  const text = Buffer.from(base64Text, 'base64').toString();\n  let decrypted = \"\";\n  for (let i = 0; i < text.length; i++) {\n    const charCode = text.charCodeAt(i) ^ key.charCodeAt(i % key.length);\n    decrypted += String.fromCharCode(charCode);\n  }\n  return decrypted;\n}\n\nreturn [\n  {\n    json: {\n      decrypted: xorDecrypt(encrypted, key)\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "83f71006-74d3-4e44-a8f7-47c5312dabf1",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "encrypt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "decrypt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流