-
-
Save krkeegan/8081a9efc11fb73aec0e51c91dd03521 to your computer and use it in GitHub Desktop.
Quick script to decrypt Node-RED credentials files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const crypto = require('crypto'); | |
| var encryptionAlgorithm = "aes-256-ctr"; | |
| function decryptCreds(key, cipher) { | |
| var flows = cipher["$"]; | |
| var initVector = Buffer.from(flows.substring(0, 32),'hex'); | |
| flows = flows.substring(32); | |
| var decipher = crypto.createDecipheriv(encryptionAlgorithm, key, initVector); | |
| var decrypted = decipher.update(flows, 'base64', 'utf8') + decipher.final('utf8'); | |
| return JSON.parse(decrypted); | |
| } | |
| var creds = require("./" + process.argv[1]) | |
| var secret = process.argv[2] | |
| var key = crypto.createHash('sha256').update(secret).digest(); | |
| console.log(decryptCreds(key, creds)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment