net.digger:crc-util

A parameterized checksum and CRC calculation tool, which supports many different algorithms and parameters.

License

License

Categories

Categories

Net
GroupId

GroupId

net.digger
ArtifactId

ArtifactId

crc-util
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

net.digger:crc-util
A parameterized checksum and CRC calculation tool, which supports many different algorithms and parameters.
Project URL

Project URL

https://github.com/diggernet/JavaCRC
Source Code Management

Source Code Management

https://github.com/diggernet/JavaCRC/tree/develop

Download crc-util

How to add to project

<!-- https://jarcasting.com/artifacts/net.digger/crc-util/ -->
<dependency>
    <groupId>net.digger</groupId>
    <artifactId>crc-util</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.digger/crc-util/
implementation 'net.digger:crc-util:1.0.0'
// https://jarcasting.com/artifacts/net.digger/crc-util/
implementation ("net.digger:crc-util:1.0.0")
'net.digger:crc-util:jar:1.0.0'
<dependency org="net.digger" name="crc-util" rev="1.0.0">
  <artifact name="crc-util" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.digger', module='crc-util', version='1.0.0')
)
libraryDependencies += "net.digger" % "crc-util" % "1.0.0"
[net.digger/crc-util "1.0.0"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

JavaCRC

JavaCRC is a parameterized checksum and CRC calculation tool, which supports many different algorithms and parameters. It is pre-configured with:

  • 8-bit checksum
  • 16-bit checksum
  • 32-bit checksum
  • CRC-16
  • CRC-16 Modbus
  • CRC-16 CCITT
  • CRC-16 CCITT (0x1D0F)
  • CRC-16 CCITT (Kermit)
  • CRC-16 CCITT (XModem)
  • CRC-16 DNP
  • CRC-32

Maven configuration

	<dependency>
		<groupId>net.digger</groupId>
		<artifactId>crc-util</artifactId>
		<version>1.0.0</version>
	</dependency>

Usage

TL;DR: Give it a configuration and a message, get back a number.

  • Can be called statically, for simple occasional use:

      String message = "...";
      long result = CRC.calculate(CRC.CRC16, message);
    
  • For more intensive use, it's faster to create an instance and use the table-driven method:

      CRC<CRCConfig, CRCComputer> crc = new CRC<>(CRC.CRC16);
      String message = "...";
      long result = crc.calculate(message);
    
  • You can also calculate the CRC incrementally:

      String message = "...";
      Long result = null;
      for (byte b : message.getBytes()) {
      	result = CRC.update(CRC.CRC16, result, b);
      }
    
      CRC<CRCConfig, CRCComputer> crc = new CRC<>(CRC.CRC16);
      String message = "...";
      Long result = null;
      for (byte b : message.getBytes()) {
      	result = crc.update(result, b);
      }
    

License

JavaCRC is provided under the terms of the GNU LGPLv3.

Versions

Version
1.0.0