-1

I need to compute a CRC 128 bit checksum for strings extracted from documents.

I am looking around on the internet but cant find any pseudo code or java code.

So anyone can help me?

Thanks for your attention.

  • 1
    It's a bit unclear what exactly you're asking. Are you doing an educational assignment that has to do with learning/implementing the algorithms (crc128, bloom filtering) or are you just looking for libraries to do this for you? Also, it too broad a question to ask if indeed you're asking SO to provide you with the code for the composition of crc computation with bloom filters. But you could ask a question for each, and be more specific whether you're looking for libraries or algorithmic theory. – plc Mar 06 '14 at 09:25
  • I am working on my thesis. I need the code that implements crc128. – Nguyen Trung Mar 06 '14 at 10:22
  • Then I definitely think you should edit the question to reflect that :-) I actually may have found something usable for you. – plc Mar 06 '14 at 10:49

2 Answers2

0

The wikipedia article on the computation of crc-checksums contains explanations on crc algorithms and shows pseudocode as well

http://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks

Andre Holzner
  • 18,333
  • 6
  • 54
  • 63
plc
  • 864
  • 8
  • 20
  • But as of today's date, the wikipedia article mentions nothing about crc128. It stops at several 64-bit CRCs. – Krazy Glew Feb 17 '15 at 19:14
0

This is totally untested... However, here is a snippet for CRC checksuming of a string... Changing the Width will alter whether it is an 8 bit, 16 bit, 32 bit, 64 bit, etc. The return type would also need to be altered if you need to full size.

Ie setting width to 8 * 16, should result in a return that is the bottom most 64 bits `

static int WIDTH = (8 * 16);// change this to 8*4 for int, and 8 * 2 for 16 bits
static int TOPBIT = (1 << (WIDTH - 1));
static int POLYNOMIAL = 0xD8; /* 11011 followed by 0's */
static long CRCFunc(final String msg)
   {
        final byte message[] = msg.getBytes();
        int nBytes = message.length;
        if(nBytes<1) return 0;
        long rem = 0; 
        int b;
        for(b=0;b<nBytes;++b)
        {
            rem ^= (message[b] << (WIDTH - 8));
            byte bit;
            for(bit=8;bit>0;--bit)
            {
                if ((rem & TOPBIT)>0)
                {
                    rem = (rem<< 1) ^ POLYNOMIAL;
                }
                else
                {
                    rem = (rem << 1);
                }
            }
        }
        return (rem);
    }
`
Zach
  • 171
  • 1
  • 3
  • Certainly 0xD8 could not be polynom for this algorithm, since it should have bottom bit set. Perhaps, it should be mirrored. Since it symmetric, its mirror will have same bit pattern: 0x1B. 0xD8 probably is polynom for "right shift algorithm": ``` if ((rem&1) != 0) { rem = (rem >> 1) ^ (0xD8 << 54); } else { rem = (rem >> 1); } ``` – funny_falcon Feb 19 '19 at 07:54
  • and question was about 128bit polynom, not 64bit. – funny_falcon Feb 19 '19 at 07:56