what-the-bank/sources/com/google/common/hash/Crc32cHashFunction.java

106 lines
18 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.hash;
import java.nio.ByteBuffer;
/* loaded from: classes2.dex */
final class Crc32cHashFunction extends AbstractHashFunction {
static final HashFunction CRC_32_C = new Crc32cHashFunction();
@Override // com.google.common.hash.HashFunction
public final int bits() {
return 32;
}
Crc32cHashFunction() {
}
@Override // com.google.common.hash.HashFunction
public final Hasher newHasher() {
return new Crc32cHasher();
}
/* loaded from: classes2.dex */
static final class Crc32cHasher extends AbstractStreamingHasher {
static final int INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S = -287056435;
private int crc0;
private int crc1;
private int crc2;
private int crc3;
private boolean finished;
static final int[] BYTE_TABLE = {0, -227835133, -516198153, 324072436, -946170081, 904991772, 648144872, -724933397, -1965467441, 2024987596, 1809983544, -1719030981, 1296289744, -1087877933, -1401372889, 1578318884, 274646895, -499825556, -244992104, 51262619, -675000208, 632279923, 922689671, -996891772, -1702387808, 1760304291, 2075979607, -1982370732, 1562183871, -1351185476, -1138329528, 1313733451, 549293790, -757723683, -1048117719, 871202090, -416867903, 357341890, 102525238, -193467851, -1436232175, 1477399826, 1264559846, -1187764763, 1845379342, -1617575411, -1933233671, 2125378298, 820201905, -1031222606, -774358714, 598981189, -143008082, 85089709, 373468761, -467063462, -1170599554, 1213305469, 1526817161, -1452612982, 2107672161, -1882520222, -1667500394, 1861252501, 1098587580, -1290756417, -1606390453, 1378610760, -2032039261, 1955203488, 1742404180, -1783531177, -878557837, 969524848, 714683780, -655182201, 205050476, -28094097, -318528869, 526918040, 1361435347, -1555146288, -1340167644, 1114974503, -1765847604, 1691668175, 2005155131, -2047885768, -604208612, 697762079, 986182379, -928222744, 476452099, -301099520, -44210700, 255256311, 1640403810, -1817374623, -2130844779, 1922457750, -1503918979, 1412925310, 1197962378, -1257441399, -350237779, 427051182, 170179418, -129025959, 746937522, -554770511, -843174843, 1070968646, 1905808397, -2081171698, -1868356358, 1657317369, -1241332974, 1147748369, 1463399397, -1521340186, -79622974, 153784257, 444234805, -401473738, 1021025245, -827320098, -572462294, 797665321, -2097792136, 1889384571, 1674398607, -1851340660, 1164749927, -1224265884, -1537745776, 1446797203, 137323447, -96149324, -384560320, 461344835, -810158936, 1037989803, 781091935, -588970148, -1834419177, 1623424788, 1939049696, -2114449437, 1429367560, -1487280117, -1274471425, 1180866812, 410100952, -367384613, -112536529, 186734380, -538233913, 763408580, 1053836080, -860110797, -1572096602, 1344288421, 1131464017, -1323612590, 1708204729, -1749376582, -2065018290, 1988219213, 680717673, -621187478, -911630946, 1002577565, -284657034, 493091189, 238226049, -61306494, -1307217207, 1082061258, 1395524158, -1589280451, 1972364758, -2015074603, -1800104671, 1725896226, 952904198, -894981883, -638100751, 731699698, -11092711, 222117402, 510512622, -335130899, -1014159676, 837199303, 582374963, -790768336, 68661723, -159632680, -450051796, 390545967, 1230274059, -1153434360, -1469116676, 1510247935, -1899042540, 2091215383, 1878366691, -1650582816, -741088853, 565732008, 854102364, -1065151905, 340358836, -433916489, -177076669, 119113024, 1493875044, -1419691417, -1204696685, 1247431312, -1634718085, 1828433272, 2141937292, -1916740209, -483350502, 291187481, 34330861, -262120466, 615137029, -691946490, -980332558, 939183345, 1776939221, -1685949482, -1999470558, 2058945313, -1368168502, 1545135305, 1330124605, -1121741762, -210866315, 17165430, 307568514, -532767615, 888469610, -962626711, -707819363, 665062302, 2042050490, -1948470087, -1735637171, 1793573966, -1104306011, 1279665062, 1595330642, -1384295599};
static final int[][] STRIDE_TABLE = {new int[]{0, 819083365, 1638166730, 1366706351, -1018633836, -207955471, -1561554594, -1841387205, -2088913447, -1280340548, -489044717, -770966154, 1077236813, 1894214696, 563160199, 289610978, 51846467, 868558118, 1655926153, 1382110700, -1067451177, -259144526, -1577350115, -1859537800, -2140493670, -1330081537, -506537904, -786636747, 1126320398, 1945137515, 579221956, 307495329, 103692934, 922485475, 1737116236, 1465414185, -983114990, -172694665, -1530745896, -1810852931, -2058121377, -1249790150, -453509227, -735721488, 1176202955, 1992906414, 666836481, 393029220, 87631813, 904601504, 1688033039, 1414492010, -965622191, -157024716, -1479166309, -1761112322, -2042326500, -1231639943, -404692266, -684533069, 1158443912, 1977502701, 614990658, 343554855, 207385868, 1015958889, 1844970950, 1563049379, -820734824, -3756803, -1364138926, -1637688265, -1893613355, -1074530128, -293228513, -564688774, 1281958209, 2092636452, 768430475, 488597998, 256600143, 1067012138, 1861163141, 1581064416, -872183333, -53366338, -1381500655, -1653227148, -1942561386, -1125849613, -309154468, -582970055, 1333672962, 2141979751, 786058440, 503870637, 175263626, 983594991, 1809203008, 1526990629, -918901218, -102197637, -1465983276, -1739790671, -1995441581, -1176649162, -391411047, -663112964, 1246174151, 2056594338, 736324365, 456217448, 157635273, 968321708, 1757487619, 1477646950, -902974627, -83915976, -1417034857, -1688470542, -1978079472, -1161109643, -339961894, -613503041, 1229981316, 2038578913, 687109710, 405163563, 414771736, 678089341, 2031917778, 1238278839, -605025396, -350080023, -1168868538, -1970912477, -1681563711, -1424529500, -94294261, -894232722, 1485684309, 1751090736, 959041183, 167507706, 464516955, 729665342, 2047575953, 1255784436, -655943985, -399167830, -1186765307, -1986961824, -1731050878, -1476363545, -109694392, -911996371, 1536860950, 1799920499, 977195996, 183299001, 513200286, 776268027, 2134024276, 1340119089, -572641014, -317978257, -1132838464, -1935115867, -1645517497, -1388749534, -61926003, -862114328, 1587774675, 1852947638, 1057485849, 265669756, 495046109, 760477112, 2082848023, 1291289970, -557241271, -300215252, -1083351933, -1883282202, -1627621372, -1372700575, -11007794, -813027157, 1572116880, 1835442677, 1007741274, 214094143, 350527252, 607561585, 1967189982, 1167251387, -676561280, -411154715, -1240986038, -2032519633, -1751569715, -1488252248, -163751417, -957390238, 1423035225, 1677980476, 896908179, 94864374, 401834583, 656521778, 1985475229, 1183173368, -725916733, -462857306, -1256254711, -2050151572, -1802618994, -1537470485, -181778620, -973570271, 1472648730, 1729425023, 912434896, 112238261, 315270546, 572038647, 1936643416, 1136454973, -779992058, -514818973, -1339673396, -2131489623, -1850273717, -1587206098, -267165567, -1061070620, 1392505311, 1647167930, 861634837, 59357552, 299743441, 554664116, 1887029275, 1085010046, -761964219, -498638560, -1288623729, -2082270742, -1835004664, -1569573523, -217809470, -1009367641, 1374219420, 1631245561, 810327126, 10396723}, new int[]{0, 1409766726, -1475433844, -66453558, 1441866729, 32929455, -33584795, -1443308509, -1411233838, -1764716, 65858910, 1475065880, -32283589, -1441517187, 1444794039, 35298289, 1378416981, 103787539, -98151463, -1373567329, 131717820, 1407094778, -1344835536, -70245002, -104153465, -1379013695, 1371804683, 96682317, -1405379218, -130234328, 70596578, 1345479332, -1538133334, -262756372, 207575078, 1482165600, -241118909, -1515748347, 1504607183, 229191305, 263435640, 1538580542, -1480777740, -205894990, 1514313361, 239453143, -229884899, -1505007269, -159839233, -1568776519, 1584898419, 175174709, -1551357930, -141591216, 193364634, 1602344924, 1570458669, 161225067, -174725471, -1584221209, 141193156, 1550662274, -1604008632, -194801650, 1297060773, 424199907, -448710359, -1320784785, 415150156, 1287251210, -1330636096, -457748602, -424815497, -1297448655, 1319337723, 446966717, -1285752930, -413424936, 458382610, 1330972756, 526871280, 1264598966, -12178
private static final ByteBuffer EMPTY = ByteBuffer.allocate(0);
Crc32cHasher() {
super(16);
this.finished = false;
this.crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
this.crc1 = 0;
this.crc2 = 0;
this.crc3 = 0;
}
@Override // com.google.common.hash.AbstractStreamingHasher
protected final void process(ByteBuffer byteBuffer) {
if (this.finished) {
throw new IllegalStateException("The behavior of calling any method after calling hash() is undefined.");
}
while (byteBuffer.remaining() >= 16) {
this.crc0 = computeForWord(this.crc0);
this.crc1 = computeForWord(this.crc1);
this.crc2 = computeForWord(this.crc2);
this.crc3 = computeForWord(this.crc3);
this.crc0 ^= byteBuffer.getInt();
this.crc1 ^= byteBuffer.getInt();
this.crc2 ^= byteBuffer.getInt();
this.crc3 ^= byteBuffer.getInt();
}
}
@Override // com.google.common.hash.AbstractStreamingHasher
protected final void processRemaining(ByteBuffer byteBuffer) {
if (this.finished) {
return;
}
int combine = combine(0, this.crc0);
this.crc0 = combine;
int combine2 = combine(combine, this.crc1);
this.crc0 = combine2;
int combine3 = combine(combine2, this.crc2);
this.crc0 = combine3;
this.crc0 = combine(combine3, this.crc3);
while (byteBuffer.hasRemaining()) {
this.crc0 = (this.crc0 >>> 8) ^ BYTE_TABLE[(byteBuffer.get() ^ this.crc0) & 255];
}
this.finished = true;
}
@Override // com.google.common.hash.AbstractStreamingHasher
protected final HashCode makeHash() {
if (!this.finished) {
processRemaining(EMPTY);
}
return HashCode.fromInt(~this.crc0);
}
static int computeForWord(int i) {
int[][] iArr = STRIDE_TABLE;
int i2 = iArr[3][i & 255];
int i3 = iArr[2][(i >>> 8) & 255];
return iArr[0][i >>> 24] ^ ((i2 ^ i3) ^ iArr[1][(i >>> 16) & 255]);
}
static int combine(int i, int i2) {
int i3 = i ^ i2;
for (int i4 = 0; i4 < 4; i4++) {
i3 = (i3 >>> 8) ^ BYTE_TABLE[i3 & 255];
}
return i3;
}
}
public final String toString() {
return "Hashing.crc32c()";
}
}