How to use the crc/lib/crc16_xmodem function in crc

To help you get started, we’ve selected a few crc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alphapoint / coinslot / src / validators / StellarValidator.js View on Github external
function calculateChecksum(payload) {
  // This code calculates CRC16-XModem checksum of payload
  // and returns it as Buffer in little-endian order.
  const checksum = new Buffer(2);
  checksum.writeUInt16LE(crc16xmodem(payload), 0);

  return checksum;
}
github LedgerHQ / ledgerjs / packages / hw-app-str / src / utils.js View on Github external
export function encodeEd25519PublicKey(rawPublicKey: Buffer): string {
  let versionByte = 6 << 3; // 'G'
  let data = Buffer.from(rawPublicKey);
  let versionBuffer = Buffer.from([versionByte]);
  let payload = Buffer.concat([versionBuffer, data]);
  let checksum = Buffer.alloc(2);
  checksum.writeUInt16LE(crc16xmodem(payload), 0);
  let unencoded = Buffer.concat([payload, checksum]);
  return base32.encode(unencoded);
}

crc

Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the browser.

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis