List of utility methods to do CRC Calculate
int | calcCRC(final byte[] data) Calculates the CRC over all config data packets (including the last with the null bytes at the end) (see page 49) final int POLY = 0x1021; final int START_VALUE = 0xFFFF; int crc = START_VALUE; for (int i = 0; i < data.length; i++) { crc = crc ^ ((data[i] & 0xFF) << 8); for (int j = 0; j < 8; j++) { if ((crc & 0x8000) == 0x8000) { crc = crc << 1; ... |
int | calcCRC(int crc, byte[] bytes, int start, int len) calc CRC initCRCCache(); for (int j = 0; j < len; ++j) { final byte b = bytes[j + start]; crc = calcCRC(crc, b); return crc; |
int | calculateCRC(byte[] buff, int count) calculate CRC int crc = 0xFFFF; int shifts = 0; int flag = 0x0000; for (int i = 0; i < buff.length && i < count; i++) { crc = (crc & 0xFF00) | ((crc ^ buff[i]) & 0x00FF); do { flag = crc & 0x0001; crc = crc >>> 1; ... |
int[] | calculateCRC(byte[] data, int offset, int len) calculate CRC int[] crc = { 0xFF, 0xFF }; int nextByte = 0; int uIndex; for (int i = offset; i < len && i < data.length; i++) { nextByte = 0xFF & ((int) data[i]); uIndex = crc[0] ^ nextByte; crc[0] = crc[1] ^ auchCRCHi[uIndex]; crc[1] = auchCRCLo[uIndex]; ... |
String | calculateCRC(String digitsToCheck) calculate CRC int sumOdd = 0; int sumEven = 0; for (int i = digitsToCheck.length() - 1; i >= 0; i--) { char c = digitsToCheck.charAt(i); Integer num = Integer.parseInt(Character.toString(c)); if (isOdd(digitsToCheck.length() - i)) sumOdd += num; else ... |
int | calculateCRC(String id) calculate CRC if (id == null || id.length() < CRC_WEIGHTS[0].length || !isDigits(id)) { return -1; int crc = CRC_INCORRECT; int weightPos = 0; while (crc == CRC_INCORRECT && weightPos < CRC_WEIGHTS.length) { crc = 0; for (int i = 0; i < ID_LENGTH - 1; i++) { ... |
short | calculateCrc16(byte[] buffer) calculate Crc return calculateCrc16(buffer, 0, buffer.length);
|
int | calculateCRC32(byte[] buf, int off, int len) Calculates the CRC32 of the given bytes. int c = 0; int end = off + len; for (int i = off; i < end; i++) { c = CRC32_TABLE[(c ^ buf[i]) & 0xFF] ^ (c >>> 8); return c; |
long | computeCRC(InputStream in) compute CRC long unitCRC = 0; BufferedInputStream bufferedInputStream = null; try { bufferedInputStream = new BufferedInputStream(in); CheckedInputStream cis = new CheckedInputStream(bufferedInputStream, new Adler32()); byte[] tempBuf = new byte[128]; while (cis.read(tempBuf) >= 0) { unitCRC = cis.getChecksum().getValue(); } catch (IOException e) { return -1; } finally { try { bufferedInputStream.close(); } catch (Exception e) { return unitCRC; |
long | computeCRC32(File file) compute CRC byte buf[] = new byte[32 * 1024]; CRC32 crc = new CRC32(); crc.reset(); FileInputStream fis = null; try { fis = new FileInputStream(file); int bytesRead; while ((bytesRead = fis.read(buf)) != -1) { ... |