|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.parser.RabinHashFunction
public final class RabinHashFunction
We compute the checksum using Broder s implementation of Rabin s fingerprinting algorithm. Fingerprints offer provably strong probabilistic guarantees that two different strings will not have the same fingerprint. Other checksum algorithms, such as MD5 and SHA, do not offer such provable guarantees, and are also more expensive to compute than Rabin fingerprint. A disadvantage is that these faster functions are efficiently invertible (that is, one can easily build an URL that hashes to a particular location), a fact that might be used by malicious users to nefarious purposes. Using the Rabin's fingerprinting function, the probability of collision of two strings s1 and s2 can be bounded (in a adversarial model for s1 and s2) by max(|s1|,|s2|)/2**(l-1), where |s1| is the length of the string s1 in bits. The advantage of choosing Rabin fingerprints (which are based on random irreducible polynomials) rather than some arbitrary hash function is that their probability of collision os well understood. Furthermore Rabin fingerprints can be computed very efficiently in software and we can take advantage of their algebraic properties when we compute the fingerprints of "sliding windows". M. O. Rabin Fingerprinting by random polynomials. Center for Research in Computing Technology Harvard University Report TR-15-81 1981 A. Z. Broder Some applications of Rabin's fingerprinting method In R.Capicelli, A. De Santis and U. Vaccaro editors Sequences II:Methods in Communications, Security, and Computer Science pages 143-152 Springer-Verlag 1993
Field Summary | |
---|---|
private byte[] |
buffer
|
private static int |
P_DEGREE
|
private long |
POLY
|
private static int |
READ_BUFFER_SIZE
|
private long[] |
table32
|
private long[] |
table40
|
private long[] |
table48
|
private long[] |
table54
|
private long[] |
table62
|
private long[] |
table70
|
private long[] |
table78
|
private long[] |
table84
|
private static int |
X_P_DEGREE
|
Constructor Summary | |
---|---|
RabinHashFunction()
Constructor for the RabinHashFunction64 object |
Method Summary | |
---|---|
long |
hash(byte[] A)
Return the Rabin hash value of an array of bytes. |
private long |
hash(byte[] A,
int offset,
int length,
long ws)
Description of the Method |
long |
hash(char[] A)
Return the Rabin hash value of an array of chars. |
long |
hash(java.io.File f)
Computes the Rabin hash value of the contents of a file. |
long |
hash(java.io.InputStream is)
Computes the Rabin hash value of the data from an InputStream . |
long |
hash(int[] A)
Returns the Rabin hash value of an array of integers. |
long |
hash(long[] A)
Returns the Rabin hash value of an array of longs. |
long |
hash(java.lang.Object obj)
Description of the Method |
long |
hash(java.io.Serializable obj)
Returns the Rabin hash value of a serializable object. |
long |
hash(java.lang.String s)
Computes the Rabin hash value of a String. |
long |
hash(java.net.URL url)
Computes the Rabin hash value of the contents of a file, specified by URL. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int P_DEGREE
private static final int READ_BUFFER_SIZE
private static final int X_P_DEGREE
private final byte[] buffer
private long POLY
private final long[] table32
private final long[] table40
private final long[] table48
private final long[] table54
private final long[] table62
private final long[] table70
private final long[] table78
private final long[] table84
Constructor Detail |
---|
public RabinHashFunction()
P
- Description of the ParameterMethod Detail |
---|
public static void main(java.lang.String[] args)
public long hash(byte[] A)
A
- the array of bytes
private long hash(byte[] A, int offset, int length, long ws)
A
- Description of the Parameteroffset
- Description of the Parameterlength
- Description of the Parameterw
- Description of the Parameter
public long hash(char[] A)
A
- the array of chars
public long hash(java.io.File f) throws java.io.FileNotFoundException, java.io.IOException
f
- the file to be hashed
java.io.FileNotFoundException
- if the file cannot be found
java.io.IOException
- if an error occurs while reading the filepublic long hash(java.io.InputStream is) throws java.io.IOException
InputStream
.
is
- the InputStream to hash
java.io.IOException
- if an error occurs while reading from the
InputStreampublic long hash(int[] A)
A
- array of integers
public long hash(long[] A)
A
- array of integers
public long hash(java.lang.Object obj) throws java.io.IOException
obj
- Description of the Parameter
java.io.IOException
- Description of the Exceptionpublic long hash(java.io.Serializable obj) throws java.io.IOException
obj
- the object to be hashed
java.io.IOException
- if serialization failspublic long hash(java.lang.String s)
s
- the string to be hashed
public long hash(java.net.URL url) throws java.io.IOException
url
- the URL of the file to be hashed
java.io.IOException
- if an error occurs while reading from the URL
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |