All Packages Class Hierarchy This Package Previous Next Index
Class Acme.Crypto.Hash
java.lang.Object
|
+----Acme.Crypto.CryptoUtils
|
+----Acme.Crypto.Hash
- public abstract class Hash
- extends CryptoUtils
A hash-function template.
Hash functions are also known as message digests or checksums.
The idea is to reduce an arbitrary-length stream of bytes down
to a fixed size, useful for comparisons, security, whatever.
Fetch the software.
Fetch the entire Acme package.
- See Also:
- StreamCipher, BlockCipher
-
hashBytes
- The hash bytes.
-
hashSize
- How big a hash is.
-
Hash(int)
- Constructor.
-
add(boolean)
- Add a boolean to the hash.
-
add(byte)
- Add a byte to the hash.
-
add(byte[])
- Add a byte array to the hash.
-
add(byte[], int, int)
- Add some bytes to the hash.
-
add(char)
- Add a char to the hash.
-
add(double)
- Add a double to the hash.
-
add(float)
- Add a float to the hash.
-
add(int)
- Add an int to the hash.
-
add(long)
- Add a long to the hash.
-
add(Object)
- Add any Object to the hash.
-
add(short)
- Add a short to the hash.
-
add(String)
- Add a String to the hash.
-
addASCII(String)
- Add a String to the hash, ignoring the high bytes of each char.
-
equals(Hash)
- Check if two hashes are equal.
-
get()
- Get the current hash.
-
hashCode()
- Compute a Java int hash code, for use with java.util.Hashtable.
-
hashSize()
- Return how big a hash is.
-
hashStr(String, Hash)
- Static utility routine for hashing a String in one step.
-
prepare()
- Prepare the hash bytes for use.
-
reset()
- Initialize (reset) the hash.
-
toString()
- Convert a Hash to a String representation.
hashSize
protected int hashSize
- How big a hash is.
hashBytes
protected byte hashBytes[]
- The hash bytes.
Hash
public Hash(int hashSize)
- Constructor. All sub-class constructors should call reset().
We can't call it here because it would get called before the
sub-class's variable initializations.
hashSize
public int hashSize()
- Return how big a hash is.
reset
public abstract void reset()
- Initialize (reset) the hash.
add
public abstract void add(byte b)
- Add a byte to the hash.
add
public void add(byte data[],
int off,
int len)
- Add some bytes to the hash. Default version just calls add(byte)
repeatedly. Can be overridden for efficiency.
prepare
protected void prepare()
- Prepare the hash bytes for use. This is called by get() just
before returning the bytes, and by other routines such as equals() and
toString() before looking at the bytes. The default implementation does
nothing, but if a subclass wants to store the hash in some
form other than a byte array, it should override this routine
and have if convert the hash to bytes and store in hashBytes.
get
public byte[] get()
- Get the current hash.
add
public void add(String str)
- Add a String to the hash.
addASCII
public void addASCII(String str)
- Add a String to the hash, ignoring the high bytes of each char.
add
public void add(byte data[])
- Add a byte array to the hash.
add
public void add(boolean b)
- Add a boolean to the hash.
add
public void add(char c)
- Add a char to the hash.
add
public void add(short s)
- Add a short to the hash.
add
public void add(int i)
- Add an int to the hash.
add
public void add(long l)
- Add a long to the hash.
add
public void add(float f)
- Add a float to the hash.
add
public void add(double d)
- Add a double to the hash.
add
public void add(Object o)
- Add any Object to the hash.
hashStr
public static byte[] hashStr(String str,
Hash hash)
- Static utility routine for hashing a String in one step.
Call like so:
byte[] hash = SomeHash.hashStr( str, new SomeHash() );
equals
public boolean equals(Hash otherHash)
- Check if two hashes are equal.
hashCode
public int hashCode()
- Compute a Java int hash code, for use with java.util.Hashtable.
A hash of a Hash.
- Overrides:
- hashCode in class Object
toString
public String toString()
- Convert a Hash to a String representation.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs