mkv

trainwreck

mkv
Nov 17th, 2012
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. // this is by far the most optimized code I've ever written,
  2. // implementing the all-time worst idea I've had yet.
  3. // surprisingly, the code also looks like shit.
  4.  
  5. void bruteforcer()
  6. {
  7.     uint acrc, bcrc, ccrc;
  8.     for (uint a = 0; a < 0x100; a++)
  9.     {
  10.         if (bruteforceNew == (CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8)))
  11.         {
  12.             bruteforceDelta = a;
  13.             bruteforceBytes = 1;
  14.             return;
  15.         }
  16.     }
  17.     for (uint a = 0; a < 0x100; a++)
  18.     {
  19.         acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
  20.         for (uint b = 0; b < 0x100; b++)
  21.         {
  22.             if (bruteforceNew == (CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8)))
  23.             {
  24.                 bruteforceDelta = a * 0x100 + b;
  25.                 bruteforceBytes = 2;
  26.                 return;
  27.             }
  28.         }
  29.     }
  30.     for (uint a = 0; a < 0x100; a++)
  31.     {
  32.         acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
  33.         for (uint b = 0; b < 0x100; b++)
  34.         {
  35.             bcrc = CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8);
  36.             for (uint c = 0; c < 0x100; c++)
  37.             {
  38.                 if (bruteforceNew == (CRC32._table[(bcrc ^ c) & 0xFF] ^ (bcrc >> 8)))
  39.                 {
  40.                     bruteforceDelta =
  41.                         a * 0x100 * 0x100 +
  42.                         b * 0x100 +
  43.                         c;
  44.                     bruteforceBytes = 3;
  45.                     return;
  46.                 }
  47.             }
  48.         }
  49.     }
  50.     for (uint a = 0; a < 0x100; a++)
  51.     {
  52.         acrc = CRC32._table[(bruteforceOld ^ a) & 0xFF] ^ (bruteforceOld >> 8);
  53.         for (uint b = 0; b < 0x100; b++)
  54.         {
  55.             bcrc = CRC32._table[(acrc ^ b) & 0xFF] ^ (acrc >> 8);
  56.             for (uint c = 0; c < 0x100; c++)
  57.             {
  58.                 ccrc = CRC32._table[(bcrc ^ c) & 0xFF] ^ (bcrc >> 8);
  59.                 for (uint d = 0; d < 0x100; d++)
  60.                 {
  61.                     if (bruteforceNew == (CRC32._table[(ccrc ^ d) & 0xFF] ^ (ccrc >> 8)))
  62.                     {
  63.                         bruteforceDelta =
  64.                             a * 0x100 * 0x100 * 0x100 +
  65.                             b * 0x100 * 0x100 +
  66.                             c * 0x100 +
  67.                             d;
  68.                         bruteforceBytes = 4;
  69.                         return;
  70.                     }
  71.                 }
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment