@dikman/crc
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

CRC

npm Downloads Monthly Downloads npm bundle size (minified + gzip) License

The library for calculating Cyclic Redundancy Check (CRC) for browser-side. The calculation is table-based. Tables are dynamically generated once per each CRC function.

This library is an adaptation and simplification of polycrc for use it on browser-side. CRC mathematics is checked with pycrc. It seems to be no other module in npm registry wich possible to use with Angular framework.

Even though this library was designed for browser-side it also keeps the possibility to use on nodejs-side.

Contents

Installation

npm install @dikman/crc

API

function crc24(str: string): Converter;
function crc32(str: string): Converter;
interface Converter {
  public toHEX(prefix: string = '0x'): string;
  public asNumber(): number;
}

Usage

Calculate a CRC32

import { crc32 } from '@dikman/crc';

const checksum = crc32('hello');

console.log(checksum.toHEX());
// "0x3610A686"

console.log(checksum.asNumber());
// 907060870

Calculate a CRC24

import { crc24 } from '@dikman/crc';

const checksum = crc24('hello');

console.log(checksum.toHEX());
// "0x47F58A"

console.log(checksum.asNumber());
// 4715914

License

The MIT License (MIT)

Copyright (c) 2020 Dmitriy Kuznetsov

Generated

This library was generated with Angular CLI version 8.2.14.

Package Sidebar

Install

npm i @dikman/crc

Weekly Downloads

8

Version

0.1.3

License

MIT

Unpacked Size

150 kB

Total Files

38

Last publish

Collaborators

  • dikman