Java CRC Calculate crc16(final byte[] bytes)

Here you can find the source of crc16(final byte[] bytes)

Description

crc

License

Apache License

Declaration

public static int crc16(final byte[] bytes) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int crc16(final byte[] bytes) {
        int crc = 0xFFFF;

        for (int j = 0; j < bytes.length; j++) {
            crc = ((crc >>> 8) | (crc << 8)) & 0xffff;
            crc ^= (bytes[j] & 0xff);// byte to int, trunc sign
            crc ^= ((crc & 0xff) >> 4);
            crc ^= (crc << 12) & 0xffff;
            crc ^= ((crc & 0xFF) << 5) & 0xffff;
        }/*w ww  .j av a 2  s  .com*/
        crc &= 0xffff;
        return crc;

    }
}

Related

  1. computeCRC(InputStream in)
  2. computeCRC32(File file)
  3. computeCrc32(InputStream is)
  4. CRC(String message)
  5. crc16(byte[] bytes)
  6. crc16_get(byte aby[], int nOffset, int nLength)
  7. CRC16_TABLE(byte[] aData, int aSize)
  8. crc32(byte[] array, int offset, int size)
  9. CRC32(final byte[] buf, final int startPos, final int endPos)