Zorba the Hutt (zorbathut) wrote,
Zorba the Hutt
zorbathut

In C, the algorithm main loop looks like this:

r=0;
while (len--)
{
byte t = (r >> 24) & 0xFF;
r = (r << 8) | *p++;
r^=table[t];
}

where len is the length of the augmented message in bytes, p points to
the augmented message, r is the register, t is a temporary, and table
is the computed table. This code can be made even more unreadable as
follows:

r=0; while (len--) r = ((r << 8) | *p++) ^ t[(r >> 24) & 0xFF];
mmmm, unreadable code ^^

the funny thing - that line is actually in a very long paper on CRCs. Who said compsci people didn't have a sense of humor? :)
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments