Flows-cred.json decrypt/encrypt dependency

I am creating a script that a user would provide a configuration file, that haves a list of:

  • settings ( for updating settings.js)
    -configurations (for nodes)

What i want to do also is for a user to be able to provide different credentials for different nodes (that are saved in flow_cred.json file). So that the program can encrypt the plaintext credentials to the cred file.

Tried looking what dependency node-red uses for this from GitHub repository, but without luck!

1 Like

The encrypt/decrypt functions are here: node-red/credentials.js at 67dd7e30faf1a6fca07f5b745de75f4ad3036ce4 · node-red/node-red · GitHub

We don't expose these in any api, but you can just copy/paste them into your own code.

const crypto = require('crypto')
// To encrypt
const originalKey = 'secret'
const credentials = { "a": "myPassword" }
const hashedKey = crypto.createHash('sha256').update(originalKey).digest();
const encryptedKeys = encryptCredentials(hashedKey, credentials)
1 Like

Hi Nick I am trying to reverse engineer this logic in python. Would there be a way where I can somehow test the decryption logic of a resultant flows_cred.json file i.e. create flows_cred.json file, mount it into a directory (via docker volumes) and see the logs of nodered whether the decryption of the file was successful or not?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.