Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this is by far the most optimized code I've ever written,
- // implementing the all-time worst idea I've had yet.
- // surprisingly, the code also looks like shit.
- void bruteforcer()
- {
- uint acrc, bcrc, ccrc;
- for (uint a = 0; a < 0x100; a++)
- {
- if (bruteforceNew == (CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8)))
- {
- bruteforceDelta = a;
- bruteforceBytes = 1;
- return;
- }
- }
- for (uint a = 0; a < 0x100; a++)
- {
- acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
- for (uint b = 0; b < 0x100; b++)
- {
- if (bruteforceNew == (CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8)))
- {
- bruteforceDelta = a * 0x100 + b;
- bruteforceBytes = 2;
- return;
- }
- }
- }
- for (uint a = 0; a < 0x100; a++)
- {
- acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
- for (uint b = 0; b < 0x100; b++)
- {
- bcrc = CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8);
- for (uint c = 0; c < 0x100; c++)
- {
- if (bruteforceNew == (CRC32._table[(bcrc ^ c) & 0xFF] ^ (bcrc >> 8)))
- {
- bruteforceDelta =
- a * 0x100 * 0x100 +
- b * 0x100 +
- c;
- bruteforceBytes = 3;
- return;
- }
- }
- }
- }
- for (uint a = 0; a < 0x100; a++)
- {
- acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
- for (uint b = 0; b < 0x100; b++)
- {
- bcrc = CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8);
- for (uint c = 0; c < 0x100; c++)
- {
- ccrc = CRC32._table[(bcrc ^ c) & 0xFF] ^ (bcrc >> 8);
- for (uint d = 0; d < 0x100; d++)
- {
- if (bruteforceNew == (CRC32._table[(ccrc ^ d) & 0xFF] ^ (ccrc >> 8)))
- {
- bruteforceDelta =
- a * 0x100 * 0x100 * 0x100 +
- b * 0x100 * 0x100 +
- c * 0x100 +
- d;
- bruteforceBytes = 4;
- return;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment