package com.gamebuster19901.excitemail; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; public class CRCTester { private final byte[] data; public CRCTester(InputStream inputStream) throws IOException { data = inputStream.readAllBytes(); } public int test(int maxLength, final int seed) { ByteBuffer param1 = ByteBuffer.wrap(data); byte pos1; byte pos2; byte pos3; byte pos4; byte pos5; byte pos6; byte bVar7; boolean bVar8; int leftoverBytes; int bytesEvaluated; @Unsigned Integer uVar11; @Unsigned Integer bytesRemaining; uVar11 = seed; if(3 < maxLength) { pos1 = param1.get(); maxLength = maxLength - 4; pos2 = param1.get(); bVar7 = pos1; pos3 = param1.get(); param1 = newAdjustedBuffer(param1, 4); uVar11 = bVar7 << 0x18 | pos1 << 0x10 | pos2 << 8 | pos3; } bytesEvaluated = 0; if(0 < maxLength) { if (8 < maxLength) { bVar8 = false; if (-1 < maxLength && maxLength < 0x7fffffff) { bVar8 = true; } if(bVar8 && (bytesRemaining = maxLength - 1 >>> 3) == 0 && 0 < maxLength - 8) { //this is almost certainty a for loop. Also bytesRemaining = (maxLength - 1) / 8 do { bytesEvaluated = bytesEvaluated + 8; uVar11 = (uVar11 << 8 | param1.getInt(0)) ^ (seed + (uVar11 >>> 0x16 & 0x3fc)); pos1 = param1.get(); pos2 = param1.get(); pos3 = param1.get(); uVar11 = (uVar11 << 8 | param1.getInt(1)) ^ (seed + (uVar11 >>> 0x16 & 0x3fc)); pos4 = param1.get(); pos5 = param1.get(); pos6 = param1.get(); param1 = newAdjustedBuffer(param1, 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)); bytesRemaining = bytesRemaining - 1; } while (bytesRemaining != 0); } } } leftoverBytes = maxLength - bytesEvaluated; if(bytesEvaluated < maxLength) { do { bVar7 = param1.get(); param1 = newAdjustedBuffer(param1, 1); uVar11 = (uVar11 << 8 | bVar7) ^ (seed + (uVar11 >>> 0x16 & 0x3fc)); leftoverBytes = leftoverBytes - 1; } while (leftoverBytes != 0); } return ~uVar11; } private ByteBuffer newAdjustedBuffer(ByteBuffer prevBuffer, int amount) { byte[] remainingBytes = new byte[prevBuffer.limit() - 1]; prevBuffer.get(remainingBytes, 1, remainingBytes.length); return ByteBuffer.wrap(remainingBytes); } }