Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. public static unsafe void Calc_crc32(long* crc32, char* mem, int ln, int fl)
  2.         {
  3.             long fcs;
  4.             int i, ii, iii;
  5.             if ((fl & 1) == 1)
  6.                 fcs = -1;
  7.             else
  8.                 fcs = *crc32;
  9.             for (i = 0; i < ln; i++)
  10.             {
  11.                 iii = mem[i];
  12.                 for (ii = 0; i < 8; i++)
  13.                 {
  14.                     if ((fcs & 1) == 1)
  15.                     {
  16.                         fcs >>= 1;
  17.                         if ((iii & 1) == 1)
  18.                             fcs |= 0x80000000;
  19.                         else
  20.                             fcs &= 0x7FFFFFFF;
  21.                         fcs ^= 0XEDB88320;
  22.                     }
  23.                     else
  24.                     {
  25.                         fcs >>= 1;
  26.                         if ((iii & 1) == 1)
  27.                             fcs |= 0x80000000;
  28.                         else
  29.                             fcs &= 0x7FFFFFFF;
  30.                     }
  31.                     iii >>= 1;
  32.                 }
  33.             }
  34.             if ((fl & 2) == 1)
  35.             {
  36.                 for (i = 0; i < 32; i++)
  37.                 {
  38.                     if ((fcs & 1) == 1)
  39.                     {
  40.                         fcs >>= 1;
  41.                         fcs &= 0x7FFFFFFF;
  42.                         fcs ^= 0xEDB88320;
  43.                     }
  44.                     else
  45.                     {
  46.                         fcs >>= 1;
  47.                         fcs &= 0x7FFFFFFF;
  48.                     }
  49.                 }
  50.                 fcs ^= -1;
  51.             }
  52.             *crc32 = fcs;
  53.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement