Sirhc
27 December 2023 21:31
1
Hello
I am trying to encrypt a password using openssl passwd and an exec node. Flow looks like this:
The code in the encrypt pin function is this:
msg.payload = "-salt abcdef" + global.get("pincode");
return msg;
pincode is a string.
The exec node has the following: openssl passwd
When I execute the function, a PID # appears under the exec node, so I know it has ran.
However I get nothing out of the exec node, it should be returning the encrypted version of the "pincode" variable.
Any ideas on what I am doing wrong?
Try using the other 2 outputs and sending them to debug to see what error is being produced. I suspect that openssl requires sudo
but I'm not sure.
Sirhc
28 December 2023 20:37
3
Thanks for the reply. I have 3 debug nodes connected to the 3 outputs set to display the complete msg object and I am seeing nothing in the debug window.
I don't think you need to be sudo, I can run that command in the terminal without beings sudo.
When you run in the terminal, you typically get an entirely different configuration - see what env variables you get in the terminal or assumptions by openssh as to the location of configuration files. These will all be different when run from within Node-RED.
I don't remember the config for openssh off the top of my head so I can't help directly, you will need to do some reading about it.
Sirhc
28 December 2023 21:01
5
that's ok, I figured it out, you need -noverify in the exec node otherwise openssl passwd sits there waiting for confirmation of the password
Sirhc
28 December 2023 21:22
6
One other issue I am having.. The exec node returns this payload:
abvc
I then have this function node to compare the result:
var alarm_function_tmp = msg.payload;
if (alarm_function_tmp === "abvc") {
var alarm_pass_fail_tmp = "ENTER PINCODE";
msg.pass=alarm_pass_fail_tmp;
msg.success = 1;
msg.passthru = alarm_function_tmp;
return msg;
} else if (alarm_function_tmp != "abvc") {
var alarm_pass_fail_tmp = "INCORRECT PIN";
msg.pass=alarm_pass_fail_tmp;
msg.passthru = alarm_function_tmp;
return msg;
}
However I cannot get the === statement to equate true.
The strings are the same? I'm not sure what I am missing
Not sure
var alarm_function_tmp = msg.payload.join("");
Can be simplified to
- } else if (alarm_function_tmp != "$1$4312$l7ibmh5zfQTHChznRX5i7.") {
+ else {
Sirhc
28 December 2023 21:35
8
Thanks for the reply but that didn't work either
Sirhc
28 December 2023 21:43
9
I got it to work, used msg.slice to clean up the exec nod
just do msg.payload.trim()
since the command line output includes a newline.
1 Like
system
Closed
26 February 2024 21:57
11
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.