Skip to content

js version of pycrc16 library - for crc16 xmodem

Notifications You must be signed in to change notification settings

i2egular/crc16xmodem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CRC16 XModem for JS

Derived from pycrc16 library implementation (Link)

For using in Node.js and Browser No dependency needed Tested and worked in Node 12, Chrome 83 (Not tested in JS import yet).


Usage

Step 1: Load script via Require / Browser script tag

// For node.js
const crc16xmodem = require('crc16-xmodem'); 
<!-- For browser -->
<script src="[path-to-file]/bundle.js"></script>
<script>
    // Should return type object if working
    console.log(typeof crc16xmodem);
</script>

Step 2: Methods

// Calculate checksum with 4 digit hex output
const originalStr = '00020101021129370016A000000677010111011300660000000005802TH53037646304';
console.log(crc16xmodem.calculateChecksum(originalStr));
// Result: 8956
// Validate from last 4 digit hex checksum
const fullStr = '00020101021129370016A000000677010111011300660000000005802TH530376463048956';
console.log(crc16xmodem.validateChecksum(fullStr));
// Result: true
// or just crc16 input string with custom initial value like 0
crc16xmodem.crc16(str, initialValue);

About

js version of pycrc16 library - for crc16 xmodem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published