List of utility methods to do CRC Calculate
String | computeCrc32(InputStream is) Compute the CRC-32 of the contents of a stream. Checksum crc = new CRC32(); int last = -1; int curr; while ((curr = is.read()) != -1) { if (curr != '\n' && last == '\r') { crc.update('\n'); if (curr != '\r') { ... |
String | CRC(String message) CRC byte[] bytes = message.getBytes(); int crc = 0x0000; for (byte b : bytes) { crc = (crc >>> 8) ^ table[(crc ^ b) & 0xff]; return Integer.toHexString(crc); |
int | crc16(byte[] bytes) crc int crc = 0x0000; for (byte b : bytes) { crc = ((crc << 8) ^ LOOKUP_TABLE[((crc >>> 8) ^ (b & 0xFF)) & 0xFF]); return crc & 0xFFFF; |
int | crc16(final byte[] bytes) crc int crc = 0xFFFF; for (int j = 0; j < bytes.length; j++) { crc = ((crc >>> 8) | (crc << 8)) & 0xffff; crc ^= (bytes[j] & 0xff); crc ^= ((crc & 0xff) >> 4); crc ^= (crc << 12) & 0xffff; crc ^= ((crc & 0xFF) << 5) & 0xffff; crc &= 0xffff; return crc; |
int | crc16_get(byte aby[], int nOffset, int nLength) crget return crc16_get(aby, nOffset, nLength, 0xffff);
|
short | CRC16_TABLE(byte[] aData, int aSize) CRTABLE short nAccum = 0; for (int i = 0; i < aSize; i++) nAccum = (short) ((nAccum << 8) ^ CRC16Table[((nAccum >>> 8) ^ aData[i]) & 0x00FF]); return nAccum; |
int | crc32(byte[] array, int offset, int size) CRC32 checksum of a byte array range int crc = 0xFFFF; for (int pos = offset; pos < offset + size; pos++) { crc ^= (int) array[pos]; for (int i = 8; i != 0; i--) { if ((crc & 0x0001) != 0) { crc >>= 1; crc ^= 0xA001; } else { ... |
int | CRC32(final byte[] buf, final int startPos, final int endPos) CRC long c = 0xFFFFFFFFL; for (int i = startPos; i < endPos; i++) { c = (crcTable[(int) ((c ^ buf[i]) & 0xFF)] ^ (c >> 8)); return (int) (c ^ 0xFFFFFFFFL); |
int | crc32(int[] table, int crc, byte[] buffer, int off, int len) This function computes / refreshes a crc32 checksum. if (table[2] == 0) { initCrc32Table(table); crc = crc ^ 0xffffffff; for (int n = 0; n < len; n++) { crc = table[(crc ^ buffer[n + off]) & 0xff] ^ (crc >>> 8); return 0xffffffff ^ crc; ... |
long | crc32(long crcin, byte[] buf, int off, int alen) crc long crc = (crcin & MAXINT_MASK) ^ MAXINT_MASK; int len = alen; while (len > 0) { crc = _crcTable[((int) crc ^ buf[off++]) & 0xFF] ^ (crc >> 8); len--; final long result = crc ^ MAXINT_MASK; return result; ... |