Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gamebuster19901.excite.crc;
- import java.io.IOException;
- import java.io.InputStream;
- import java.nio.ByteBuffer;
- import org.apache.commons.io.IOUtils;
- public class CRCTester {
- private final byte[] data;
- public CRCTester(InputStream inputStream) throws IOException {
- this(IOUtils.toByteArray(inputStream));
- }
- public CRCTester(byte[] data) {
- this.data = data;
- }
- public int test(final int seed) {
- ByteBuffer param1 = ByteBuffer.wrap(data);
- int length = data.length;
- byte pos1;
- byte pos2;
- byte pos3;
- byte pos4;
- byte pos5;
- byte pos6;
- byte bVar7;
- boolean bVar8;
- int leftoverBytes;
- int bytesEvaluated;
- @Unsigned int uVar11;
- @Unsigned int cyclesRemaining;
- uVar11 = seed;
- int dataPointer = 0;
- if(3 < length) {
- pos1 = param1.get(0);
- length = length - 4;
- pos2 = param1.get(1);
- bVar7 = pos1;
- pos3 = param1.get(2);
- param1.getInt();
- dataPointer = dataPointer + 4;
- uVar11 = ~(bVar7 << 0x18 | pos1 << 0x10 | pos2 << 8 | pos3);
- }
- bytesEvaluated = 0;
- if(0 < length) {
- if (8 < length) {
- bVar8 = false;
- if (-1 < length && length < 0x7fffffff) {
- bVar8 = true;
- }
- cyclesRemaining = length - 1 >>> 3;
- if(bVar8
- && 0 < length - 8) { //this is almost certainty a for loop. Also cyclesRemaining = (maxLength - 1) / 8
- do {
- bytesEvaluated = bytesEvaluated + 8;
- uVar11 = (uVar11 << 8 | param1.getInt(0)) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- pos1 = param1.get(dataPointer + 1);
- pos2 = param1.get(dataPointer + 2);
- pos3 = param1.get(dataPointer + 3);
- uVar11 = (uVar11 << 8 | param1.getInt(1)) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- pos4 = param1.get(dataPointer + 4);
- pos5 = param1.get(dataPointer + 5);
- pos6 = param1.get(dataPointer + 6);
- param1.getLong();
- dataPointer = dataPointer + 8;
- uVar11 = (uVar11 << 8 | pos1) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- uVar11 = (uVar11 << 8 | pos2) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- uVar11 = (uVar11 << 8 | pos3) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- uVar11 = (uVar11 << 8 | pos4) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- uVar11 = (uVar11 << 8 | pos5) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- uVar11 = (uVar11 << 8 | pos6) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- cyclesRemaining = cyclesRemaining - 1;
- }
- while (cyclesRemaining != 0);
- }
- }
- leftoverBytes = length - bytesEvaluated;
- if(bytesEvaluated < length) {
- do {
- bVar7 = param1.get(dataPointer);
- dataPointer = dataPointer++;
- uVar11 = (uVar11 << 8 | bVar7) ^ (seed + (uVar11 >>> 0x16 & 0x3fc));
- leftoverBytes = leftoverBytes - 1;
- }
- while (leftoverBytes != 0);
- }
- }
- return ~uVar11;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement