[HN Gopher] Show HN: Super Simple CRC32 Implementation
       ___________________________________________________________________
        
       Show HN: Super Simple CRC32 Implementation
        
       I written this as a little programming exercise in C
        
       Author : dch82
       Score  : 4 points
       Date   : 2024-10-29 14:42 UTC (4 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | Someone wrote:
       | I suggest you write a few test cases to verify that it works
       | reliably. I have my doubts about that, given this code fragment:
       | // stop hashing when there is nothing left to hash         while
       | (scanf("%d", &ch) != EOF) {             // get the current byte
       | ch = getchar();
        
         | dch82 wrote:
         | How would you suggest I replace that? I am a C novice but I
         | have heard of the buffer overflows caused by scanf.
        
         | dch82 wrote:
         | I replaced that code with                 // loop until an EOF
         | is read       while ((ch = getchar()), ch != EOF) {
         | 
         | Would this be better?
        
       | Sianko wrote:
       | So there are many different flavors of crc32. Usually you can
       | always change the initialization value. This algorithm is only
       | one use case.
       | 
       | Check this table out
       | https://www.crccalc.com/?crc=123456789&method=&datatype=0&ou...
        
         | ranger_danger wrote:
         | I would really appreciate someone documenting exactly which
         | variant of CRC32 is being used here.
        
           | self_awareness wrote:
           | CRC-32/ISO-HDLC
           | 
           | https://www.crccalc.com/?crc=123456789&method=CRC-32%2FISO-H.
           | ..
        
       | rurban wrote:
       | A normal table-based crc32. Since we don't see the generator, we
       | cannot see the polynom. You usually put the generator in the code
        
       ___________________________________________________________________
       (page generated 2024-11-02 23:00 UTC)