Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java compatible cksum function

Is there any library/code in Java to calculate the 32-bit CRC of a stream of bytes in a way thats consistent with the cksum command in unix ?

like image 334
Kowshik Avatar asked Oct 12 '11 20:10

Kowshik


2 Answers

Jacksum: http://www.jonelo.de/java/jacksum/index.html

cksum         algorithm:   POSIX 1003.2 CRC algorithm
              length:      32 bits
              type:        crc
              since:       Jacksum 1.0.0
              comment:     - under BeOS    it is /bin/cksum
                           - under FreeBSD it is /usr/bin/cksum
                           - under HP-UX   it is /usr/bin/cksum and
                             /usr/bin/sum -p
                           - under IBM AIX it is /usr/bin/cksum
                           - under Linux   it is /usr/bin/cksum 

It's open source with GPL licence.

like image 84
palacsint Avatar answered Oct 05 '22 23:10

palacsint


Have you tried the CRC32 class?

http://download.oracle.com/javase/7/docs/api/java/util/zip/CRC32.html

This is the crc 32 which gzip uses.

like image 24
Peter Lawrey Avatar answered Oct 05 '22 23:10

Peter Lawrey