Here you can find the source of calculateCrc16(byte[] buffer)
public static short calculateCrc16(byte[] buffer)
//package com.java2s; /**//w w w. j a v a 2 s . co m * Confidential Information. * Copyright (C) 2007-2009 Eric Link, All rights reserved. * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. **/ public class Main { private static final short[] crcTable = new short[256]; public static short calculateCrc16(byte[] buffer) { return calculateCrc16(buffer, 0, buffer.length); } public static short calculateCrc16(byte[] buffer, int offset, int length) { short crc = (short) 0xffff; //x25 CCITT-CRC16 seed for (int i = 0; i < length; i++) { crc = (short) (crcTable[(buffer[i + offset] ^ (crc >>> 8)) & 0xff] ^ (crc << 8)); } return crc; } }