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

Variable Index

 o hashBytes
The hash bytes.
 o hashSize
How big a hash is.

Constructor Index

 o Hash(int)
Constructor.

Method Index

 o add(boolean)
Add a boolean to the hash.
 o add(byte)
Add a byte to the hash.
 o add(byte[])
Add a byte array to the hash.
 o add(byte[], int, int)
Add some bytes to the hash.
 o add(char)
Add a char to the hash.
 o add(double)
Add a double to the hash.
 o add(float)
Add a float to the hash.
 o add(int)
Add an int to the hash.
 o add(long)
Add a long to the hash.
 o add(Object)
Add any Object to the hash.
 o add(short)
Add a short to the hash.
 o add(String)
Add a String to the hash.
 o addASCII(String)
Add a String to the hash, ignoring the high bytes of each char.
 o equals(Hash)
Check if two hashes are equal.
 o get()
Get the current hash.
 o hashCode()
Compute a Java int hash code, for use with java.util.Hashtable.
 o hashSize()
Return how big a hash is.
 o hashStr(String, Hash)
Static utility routine for hashing a String in one step.
 o prepare()
Prepare the hash bytes for use.
 o reset()
Initialize (reset) the hash.
 o toString()
Convert a Hash to a String representation.

Variables

 o hashSize
 protected int hashSize
How big a hash is.

 o hashBytes
 protected byte hashBytes[]
The hash bytes.

Constructors

 o 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.

Methods

 o hashSize
 public int hashSize()
Return how big a hash is.

 o reset
 public abstract void reset()
Initialize (reset) the hash.

 o add
 public abstract void add(byte b)
Add a byte to the hash.

 o 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.

 o 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.

 o get
 public byte[] get()
Get the current hash.

 o add
 public void add(String str)
Add a String to the hash.

 o addASCII
 public void addASCII(String str)
Add a String to the hash, ignoring the high bytes of each char.

 o add
 public void add(byte data[])
Add a byte array to the hash.

 o add
 public void add(boolean b)
Add a boolean to the hash.

 o add
 public void add(char c)
Add a char to the hash.

 o add
 public void add(short s)
Add a short to the hash.

 o add
 public void add(int i)
Add an int to the hash.

 o add
 public void add(long l)
Add a long to the hash.

 o add
 public void add(float f)
Add a float to the hash.

 o add
 public void add(double d)
Add a double to the hash.

 o add
 public void add(Object o)
Add any Object to the hash.

 o 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() );

 o equals
 public boolean equals(Hash otherHash)
Check if two hashes are equal.

 o 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
 o 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