• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CRC32Hash
3  *
4  * Authors: Lasse Collin <lasse.collin@tukaani.org>
5  *          Igor Pavlov <http://7-zip.org/>
6  *
7  * This file has been put into the public domain.
8  * You can do whatever you want with this file.
9  */
10 
11 package org.tukaani.xz.lz;
12 
13 /**
14  * Provides a CRC32 table using the polynomial from IEEE 802.3.
15  */
16 class CRC32Hash {
17     private static final int CRC32_POLY = 0xEDB88320;
18 
19     static final int[] crcTable = new int[256];
20 
21     static {
22         for (int i = 0; i < 256; ++i) {
23             int r = i;
24 
25             for (int j = 0; j < 8; ++j) {
26                 if ((r & 1) != 0)
27                     r = (r >>> 1) ^ CRC32_POLY;
28                 else
29                     r >>>= 1;
30             }
31 
32             crcTable[i] = r;
33         }
34     }
35 }
36