Package org.seppiko.commons.utils
Class CRC16
java.lang.Object
org.seppiko.commons.utils.CRC16
- All Implemented Interfaces:
java.util.zip.Checksum
public class CRC16
extends java.lang.Object
implements java.util.zip.Checksum
A class that can be used to compute the CRC-16 of a data stream.
- Author:
- Leonard Woo
-
Constructor Summary
Constructors Constructor Description CRC16()Create CRC-16 object -
Method Summary
Modifier and Type Method Description longgetValue()Returns CRC-16 value.voidreset()Resets CRC-16 to initial value.voidupdate(byte[] b, int off, int len)Updates the CRC-16 checksum with the specified array of bytes.voidupdate(int b)Updates the CRC-16 checksum with the specified byte (the low eight bits of the argument b).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.zip.Checksum
update, update
-
Constructor Details
-
CRC16
public CRC16()Create CRC-16 object
-
-
Method Details
-
update
public void update(int b)Updates the CRC-16 checksum with the specified byte (the low eight bits of the argument b).- Specified by:
updatein interfacejava.util.zip.Checksum- Parameters:
b- number
-
update
public void update(byte[] b, int off, int len) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsExceptionUpdates the CRC-16 checksum with the specified array of bytes.- Specified by:
updatein interfacejava.util.zip.Checksum- Parameters:
b- dataoff- data init offsetlen- data length- Throws:
java.lang.NullPointerException- data is nulljava.lang.ArrayIndexOutOfBoundsException- if off is negative, or len is negative, or off+len is negative * or greater than the length of the array b
-
getValue
public long getValue()Returns CRC-16 value.- Specified by:
getValuein interfacejava.util.zip.Checksum- Returns:
- CRC-16
-
reset
public void reset()Resets CRC-16 to initial value.- Specified by:
resetin interfacejava.util.zip.Checksum
-