I'm trying to encode a simple string into base64 and it doesn't work. Where is my mistake?
This is my simple flow. It is an injection of payload string and I use msg.payload.toString('base64') function that return the payload unchanged.
[
{
"id": "2b928680670e4e84",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "edf6c1fde29fbbc9",
"type": "inject",
"z": "2b928680670e4e84",
"name": "Off",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "0",
"payloadType": "str",
"x": 270,
"y": 220,
"wires": [
[
"c813605ba3679017"
]
]
},
{
"id": "c813605ba3679017",
"type": "function",
"z": "2b928680670e4e84",
"name": "",
"func": "\nmsg.payload.toString(\"base64\");\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 220,
"wires": [
[
"d042f113ad2a7a3a"
]
]
},
{
"id": "d042f113ad2a7a3a",
"type": "debug",
"z": "2b928680670e4e84",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 670,
"y": 220,
"wires": []
}
]
This the result:
Thanks for the help.