01: package org.bouncycastle.bcpg;
02:
03: public class CRC24 {
04: private static final int CRC24_INIT = 0x0b704ce;
05: private static final int CRC24_POLY = 0x1864cfb;
06:
07: private int crc = CRC24_INIT;
08:
09: public CRC24() {
10: }
11:
12: public void update(int b) {
13: crc ^= b << 16;
14: for (int i = 0; i < 8; i++) {
15: crc <<= 1;
16: if ((crc & 0x1000000) != 0) {
17: crc ^= CRC24_POLY;
18: }
19: }
20: }
21:
22: public int getValue() {
23: return crc;
24: }
25:
26: public void reset() {
27: crc = CRC24_INIT;
28: }
29: }
|