Creating CRC16 xModem Hex Value

Did you try this: CRC-32 can't get the correct check sum - any help appreciated - #5 by Steve-Mcl

Forget for a second the title states "CRC-32" - under the hood it is a universal solution.

Example:

[{"id":"e2beeb574d982801","type":"inject","z":"166e28321a352483","name":"JSON encoded base64","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"eyAia2V5IjogInZhbHVlIiB9","payloadType":"str","x":420,"y":240,"wires":[["4bf21b40a1445e15"]]},{"id":"4bf21b40a1445e15","type":"function","z":"166e28321a352483","name":"easy-crc","func":"//See https://www.npmjs.com/package/easy-crc?activeTab=readme for list of supported algorithms\n\nconst { crc16 } = easyCrc;\nconst data = Buffer.from(msg.payload, 'base64'); // if base64 encoded string\nmsg.payload = crc16('XMODEM', data)\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[{"var":"easyCrc","module":"easy-crc"}],"x":600,"y":240,"wires":[["25cd665db5eaa0d9"]]},{"id":"25cd665db5eaa0d9","type":"debug","z":"166e28321a352483","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":750,"y":240,"wires":[]},{"id":"38bebaafa0df23fd","type":"inject","z":"166e28321a352483","name":"JSON string","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"key\": \"value\" }","payloadType":"str","x":390,"y":320,"wires":[["116fd588198b5f41"]]},{"id":"116fd588198b5f41","type":"function","z":"166e28321a352483","name":"easy-crc","func":"//See https://www.npmjs.com/package/easy-crc?activeTab=readme for list of supported algorithms\n\nconst { crc16 } = easyCrc;\nconst data = Buffer.from(msg.payload, 'utf-8'); // if JSON string\nmsg.payload = crc16('XMODEM', data)\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[{"var":"easyCrc","module":"easy-crc"}],"x":600,"y":320,"wires":[["bb86f44366cee582"]]},{"id":"bb86f44366cee582","type":"debug","z":"166e28321a352483","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":750,"y":320,"wires":[]}]

For the record. Java is a completely different language than what Node-RED runs on. Node-RED / NodeJS runs on JavaScript :slight_smile: