All Projects → snksoft → java-crc

snksoft / java-crc

Licence: BSD-3-Clause license
Generic CRC implementation for java language (includes CRC16, CRC32, CRC64 etc)

Programming Languages

groovy
2714 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to java-crc

crc
Generic CRC implementation for go language (golang, includes CRC16, CRC32, CRC64 etc)
Stars: ✭ 43 (+22.86%)
Mutual labels:  crc, crc-32, crc-16, crc-8, crc-64
CRC-manipulator
Change CRC checksums of your files.
Stars: ✭ 73 (+108.57%)
Mutual labels:  crc
argocd-operator-helm
[DEPRECATED] Argo CD Operator (Helm) installs Argo CD in OpenShift and Kubernetes.
Stars: ✭ 18 (-48.57%)
Mutual labels:  crc
cfv
Command-line File Verify
Stars: ✭ 36 (+2.86%)
Mutual labels:  crc
Crc16
A simple crc-16 library for Arduino
Stars: ✭ 38 (+8.57%)
Mutual labels:  crc
twitivity
🐍 Twitter Accounts Activity API Client Library for Python
Stars: ✭ 49 (+40%)
Mutual labels:  crc
crc
A Pure Rust Implementation of Generic CRC Algorithm
Stars: ✭ 24 (-31.43%)
Mutual labels:  crc
odf-nano
ODF-Nano lets you deploy OpenShift Data Foundation on your Laptop (CRC)
Stars: ✭ 37 (+5.71%)
Mutual labels:  crc
crc16
A native node addon to calcalate and verify CRC16 values, adopted by MODBUS agreement
Stars: ✭ 24 (-31.43%)
Mutual labels:  crc
SpinalCrypto
SpinalHDL - Cryptography libraries
Stars: ✭ 36 (+2.86%)
Mutual labels:  crc
hash-checker
Fast and simple application that allows you to generate and compare hashes from files and text
Stars: ✭ 72 (+105.71%)
Mutual labels:  crc-32

This package implements generic CRC calculations up to 64 bits wide. It aims to be fairly fast and fairly complete, allowing users to match pretty much any CRC algorithm used in the wild by choosing appropriate Parameters. This obviously includes all popular CRC algorithms, such as CRC64-ISO, CRC64-ECMA, CRC32, CRC32C, CRC16, CCITT, XMODEM and many others. See http://reveng.sourceforge.net/crc-catalogue/ for a good list of CRC algorithms and their parameters.

This package has been largely inspired by Ross Williams' 1993 paper "A Painless Guide to CRC Error Detection Algorithms".

Usage

Using src is easy. Here is an example of calculating CCITT crc.

import com.github.snksoft.crc.CRC;

public class Example
{
    public static void main(String [] args) {
        String data = "123456789";
        long ccittCrc = CRC.calculateCRC(CRC.Parameters.CCITT, data.getBytes());
        System.out.printf("CRC is 0x%04X\n", ccittCrc); // prints "CRC is 0x29B1"

    }
}

For larger data, table driven implementation is faster. Here is how to use it.

import com.github.snksoft.crc.CRC;

public class Example
{
    public static void main(String [] args) {
        String data = "123456789";
       	CRC tableDriven = new CRC(CRC.Parameters.XMODEM);
       	long xmodemCrc = tableDriven.calculateCRC(data.getBytes());
        System.out.printf("CRC is 0x%04X\n", xmodemCrc); // prints "CRC is 0x31C3"

       	// You can also reuse CRC object instance for another crc calculation.
        // Given that the only state for a CRC calculation is the "intermediate value"
        // and it is stored in your code, you can even use same CRC instance to calculate CRC
        // of multiple data sets in parallel.
       	// And if data is too big, you may feed it in chunks
       	long curValue = tableDriven.init(); // initialize intermediate value
       	curValue = tableDriven.update(curValue, "123456789".getBytes()); // feed first chunk
        curValue = tableDriven.update(curValue, "01234567890".getBytes()); // feed next chunk
       	long xmodemCrc2 = tableDriven.finalCRC(curValue); // gets CRC of whole data ("12345678901234567890")
        System.out.printf("CRC is 0x%04X\n", xmodemCrc2); // prints "CRC is 0x2C89"
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].