All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.joyzl.network.verifies.CRC16_CCITT Maven / Gradle / Ivy

The newest version!
/*-
 * www.joyzl.net
 * 中翌智联(重庆)科技有限公司
 * Copyright © JOY-Links Company. All rights reserved.
 */
package com.joyzl.network.verifies;

/**
 * CRC-16/CCITT
 * 
    *
  • 名称(Name): CRC-16/CCITT *
  • 公式(Formula): x16+x12+x5+1
  • *
  • 多项式(Poly): 0x1021
  • *
  • 初始值(Init): 0x0000
  • *
  • 输入反转(Refin): True
  • *
  • 输出反转(Refout): True
  • *
  • 结果异或(Xorout): 0x0000
  • *
  • 别名(Alias): CRC-CCITT,CRC-16/CCITT-TRUE,CRC-16/KERMIT
  • *
  • 备注(Note):
  • *
* * @author ZhangXi * */ public final class CRC16_CCITT extends Verifier { short crc = 0; @Override public byte check(byte value) { crc ^= value; for (int i = 0; i < 8; i++) { if ((crc & 1) != 0) { // 0x8408 = reverse 0x1021 crc = (short) ((crc >> 1) ^ 0x8408); } else { crc = (short) (crc >> 1); } } return value; } @Override public int value() { return crc; } @Override public void reset() { crc = 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy