themadcreator / rabinfingerprint

A very collision-resistant fingerprint method.
Other
58 stars 27 forks source link

Different fingerprints for same document #3

Closed srachuri closed 9 years ago

srachuri commented 10 years ago

I m trying to generate fingerprint for a string. Below is the code snippet

    String s = "quick brown";
    Polynomial polynomial = Polynomial.createIrreducible(53);
    RabinFingerprintLong rabin = new RabinFingerprintLong(polynomial);
    rabin.pushBytes(s.getBytes());
    System.out.println(rabin.getFingerprintLong());
    System.out.println(Long.toString(rabin.getFingerprintLong(), 16));

I am always seeing new values for the same string that i m trying to finger print. I was planning to use the fingerprint for detecting duplicate documents. Not sure if the code is working as expected or i am missing any thing here?

davidholiday commented 9 years ago

did you use the same key in both instances?

themadcreator commented 9 years ago

In line 2 of this code block you generate a NEW irreducible polynomial every time this runs. To avoid this, you need to use the same polynomial each time.

Try printing out the hex digits of the polynomial and then construct the polynomial with that string.