I want to create an HMAC of a string, then encode it in base64. For that, I installed node-red-contrib-crypto-js in the palette.
Here is what I have done:
[{"id":"2aec555f.d07e6a","type":"tab","label":"here","disabled":false,"info":""},{"id":"47573c5f.fdd6e4","type":"inject","z":"2aec555f.d07e6a","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\": 3, \"b\": 5}","payloadType":"json","x":310,"y":80,"wires":[["5fa3a276.ae6fcc"]]},{"id":"4e411311.dbecec","type":"debug","z":"2aec555f.d07e6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1210,"y":240,"wires":[]},{"id":"72fc1e2a.3345f","type":"hmac","z":"2aec555f.d07e6a","name":"","algorithm":"HmacSHA256","key":"secret","x":550,"y":180,"wires":[["c3f2ca1c.889268","83896ac8.530f48"]]},{"id":"5fa3a276.ae6fcc","type":"json","z":"2aec555f.d07e6a","name":"","property":"payload","action":"str","pretty":false,"x":390,"y":160,"wires":[["72fc1e2a.3345f"]]},{"id":"1cde8689.66eb39","type":"encode","z":"2aec555f.d07e6a","name":"64","encode":"Base64","x":870,"y":240,"wires":[["4e411311.dbecec"]]},{"id":"c3f2ca1c.889268","type":"encode","z":"2aec555f.d07e6a","name":"utf","encode":"Utf8","x":710,"y":200,"wires":[["1cde8689.66eb39","3175a0ac.8bde2"]]},{"id":"83896ac8.530f48","type":"debug","z":"2aec555f.d07e6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":840,"y":120,"wires":[]},{"id":"3175a0ac.8bde2","type":"debug","z":"2aec555f.d07e6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":160,"wires":[]}]
The HMAC is correctly created but when I encode it in utf 8, it gives me an empty string. Why???
- the encode in base64 node doesn't take a string as an input, it wants an utf8 encoded string. But as I said, the utf8 encoded string is empty. What can I do?