|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.util.SHADigest
The class SHADigest
computes the digest (or hash)
of the specified content, and enables various other classes
to compare the digests and store them in a HashMap
or other collections in need of a hashCode method.
Field Summary | |
protected static java.security.MessageDigest |
digest
Message digest generator used to produce hash values for strings |
static int |
DIGEST_SIZE
Byte size of the digest values |
static java.lang.String |
DIGEST_TYPE
Name of the digest function to be used |
protected int |
hashcode
To avoid recomputing the hash of a big integer we save it |
protected static java.util.Random |
random
Proxy for obtaining random numbers. |
static java.lang.String |
RANDOM_TYPE
Name of the random function to be used |
protected java.math.BigInteger |
rdigest
A big integer for the hash code of the specified keyword. |
Constructor Summary | |
SHADigest()
Default constructor for externalization. |
|
SHADigest(boolean secure)
Creates a new SHADigest instance based on a randomly
generated SHA hash. |
Method Summary | |
int |
compareTo(java.lang.Object obj)
|
int |
compareTo(SHADigest kwHash)
|
protected void |
computeDigest(java.lang.String str)
Compute a SHA-1 hash value for the specified string |
protected void |
computeHash()
Computes the hash code for the object. |
protected void |
computeRandomSHA()
Compute a random SHA-1 hash value for a simulated hash. |
boolean |
equals(java.lang.Object obj)
Check whether this SHADigest is equal to the specified object. |
int |
hashCode()
Returns a hash code value for the object. |
protected void |
initRandom(boolean secure)
Initialize a random generator. |
void |
readExternal(java.io.ObjectInput in)
Marshals this SHADigest to the specified input stream. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
writeExternal(java.io.ObjectOutput out)
Marshals this SHADigest to the specified output stream. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.math.BigInteger rdigest
protected int hashcode
public static final java.lang.String RANDOM_TYPE
public static final java.lang.String DIGEST_TYPE
public static final int DIGEST_SIZE
protected static java.util.Random random
protected static java.security.MessageDigest digest
Constructor Detail |
public SHADigest()
public SHADigest(boolean secure)
SHADigest
instance based on a randomly
generated SHA hash.secure
- if true, the secure random generator will be used;
otherwise the standard random generator is used.Method Detail |
protected void computeDigest(java.lang.String str)
str
- The string for which to compute a SHA-1 hash.protected void computeRandomSHA()
protected void computeHash()
protected void initRandom(boolean secure)
secure
- if true, the secure random generator will be used;
otherwise the standard random generator is used.public int compareTo(java.lang.Object obj) throws java.lang.ClassCastException
compareTo
in interface java.lang.Comparable
public int compareTo(SHADigest kwHash)
public boolean equals(java.lang.Object obj)
SHADigest
is equal to the specified object.equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
SHADigest
to the specified input stream.readExternal
in interface java.io.Externalizable
in
- an ObjectInput
stream objectjava.io.IOException
- if an error occurspublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
SHADigest
to the specified output stream.writeExternal
in interface java.io.Externalizable
out
- an ObjectOutput
stream objectjava.io.IOException
- if an error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |