BlueBear icon

crc.c

BlueBear | PRO | 03/11/13 04:09:40 PM UTC | 0 ⭐ | 361 👁️ | Never ⏰ | []
C |

1.07 KB

|

None

|

0 👍

/

0 👎

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
 
uint32_t crc_table[256];
 
//hash table initialization, call this procedure beforehand we proceed to
//the hashing function
void initTable(void)
{
    uint32_t i = 0;
    int j = 0;
 
    for (i = 0; i < 256; i++)
    {
        uint32_t c = i;
 
        for (j = 0; j < 8; j++)
        {
            c = (c & 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1);
        }
 
        crc_table[i] = c;
    }
}
 
//this function generates the CRC checksum for the string we put in
uint32_t makeCrc(uint8_t *buf, size_t len)
{
    uint32_t c = 0xFFFFFFFF;
    size_t i = 0;
 
    for (i = 0; i < len; i++)
    {
        c = crc_table[(c ^ buf[i]) & 0xFF] ^ (c >> 8);
    }
 
    return c ^ 0xFFFFFFFF;
}
 
int main()
{
    //we initialize the string we want to hash
    const char *crcString = "The quick brown fox jumps over the lazy dog";
 
    //fill the hash table
    initTable();
 
    //print out
    printf("CRC hash: %X", makeCrc(crcString, strlen(crcString)));
 
    return 0;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Syutrsz icon
    03/31/26 11:00:43 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎