Add Crypto.json
This commit is contained in:
130
Crypto.json
Normal file
130
Crypto.json
Normal file
@@ -0,0 +1,130 @@
|
||||
{
|
||||
"updatedAt": "2026-04-05T08:26:11.546Z",
|
||||
"createdAt": "2026-04-04T19:28:29.276Z",
|
||||
"id": "W2OEeYHl5e7PhC21",
|
||||
"name": "Crypto",
|
||||
"active": false,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-272,
|
||||
0
|
||||
],
|
||||
"id": "23d848a0-de09-464a-a77e-9eb2965bbbaf",
|
||||
"name": "When clicking ‘Execute workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const fs = require('fs');\n\nconst pathsToCheck = [\n '/home/node/.n8n',\n '/home/node/.n8n/crypto_utils.js',\n './crypto_utils.js'\n];\n\nconst results = {};\n\npathsToCheck.forEach(p => {\n try {\n results[p] = fs.existsSync(p) ? 'Gefunden' : 'Nicht da';\n if (fs.lstatSync(p).isDirectory()) {\n results[p + '_inhalt'] = fs.readdirSync(p);\n }\n } catch (e) {\n results[p] = 'Fehler: ' + e.message;\n }\n});\n\nreturn results;"
|
||||
},
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
112,
|
||||
192
|
||||
],
|
||||
"id": "72597a2d-a899-4bc3-919f-c7b11ed39942",
|
||||
"name": "Code in JavaScript2",
|
||||
"executeOnce": false
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "67c488b2-bd53-483d-8ac5-f0561b4138d8",
|
||||
"name": "crypto",
|
||||
"value": "const crypto = require('crypto');\n\nfunction encrypt(text, encryption_key) {\n // 2. Erzeuge einen zufälligen Initialisierungsvektor (IV)\n const iv = crypto.randomBytes(16);\n \n // 3. Cipher-Objekt erstellen\n const cipher = crypto.createCipheriv('aes-256-gcm', Buffer.from(encryption_key), iv);\n\n // 4. Verschlüsseln\n let encrypted = cipher.update(text, 'utf8', 'hex');\n encrypted += cipher.final('hex');\n\n // 5. Den Authentifizierungs-Tag abrufen (WICHTIG bei GCM)\n const authTag = cipher.getAuthTag().toString('hex');\n\n // 6. Alles zusammenfügen: iv + verschlüsselter Text + Tag\n // Wir trennen sie mit Doppelpunkten, damit wir sie später leicht splitten können\n return iv.toString('hex') + ':' + encrypted + ':' + authTag;\n}\n\n// 1. Konfiguration (Diese Werte sollten aus Umgebungsvariablen kommen!)\n// Der Key muss exakt 32 Zeichen lang sein für AES-256\nconst encryption_key = '12345678901234567890123456789012'; \n\n/**\n * Entschlüsselt einen String\n * @param {string} text - Der verschlüsselte String im Format \"iv:content:tag\"\n */\nfunction decrypt(text, encryption_key) {\n const textParts = text.split(':');\n const iv = Buffer.from(textParts.shift(), 'hex');\n const encryptedText = Buffer.from(textParts.shift(), 'hex');\n const authTag = Buffer.from(textParts.shift(), 'hex'); // GCM Modus nutzt Auth Tags zur Sicherheit\n\n const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(encryption_key), iv);\n decipher.setAuthTag(authTag);\n\n let decrypted = decipher.update(encryptedText, 'hex', 'utf8');\n decrypted += decipher.final('utf8');\n\n return decrypted;\n}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [
|
||||
-80,
|
||||
192
|
||||
],
|
||||
"id": "cb79b374-2a81-401f-861d-7854e0e54879",
|
||||
"name": "js_functions",
|
||||
"alwaysOutputData": false,
|
||||
"executeOnce": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const { encrypt, decrypt } = require('/home/node/.n8n/crypto_utils.js');\n\nconst key = '12345678901234567890123456789012';\nconst text = \"Geheimnis\";\n\nreturn {\n result: encrypt(text, key)\n};"
|
||||
},
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
112,
|
||||
16
|
||||
],
|
||||
"id": "cbdb7f21-f770-4085-8524-08bd1ca8ba98",
|
||||
"name": "Code in JavaScript"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Execute workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "js_functions",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"js_functions": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Code in JavaScript2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code in JavaScript",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code in JavaScript2": {
|
||||
"main": [
|
||||
[]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"pinData": {},
|
||||
"versionId": "56cddc4b-446a-4212-8c91-e5e7ce2b3c47",
|
||||
"activeVersionId": null,
|
||||
"triggerCount": 0,
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-04-04T19:28:29.279Z",
|
||||
"createdAt": "2026-04-04T19:28:29.279Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "W2OEeYHl5e7PhC21",
|
||||
"projectId": "cSAaWNJydnksD5EB"
|
||||
}
|
||||
],
|
||||
"activeVersion": null,
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user