ostore.util
Interface SecureHash

All Superinterfaces:
Cloneable, Comparable, QuickSerializable
All Known Implementing Classes:
SHA1Hash

public interface SecureHash
extends Cloneable, Comparable, QuickSerializable

SecureHash is the interface used to represent classes which are secure hashes An example is the SHA1 hash

Version:
$Id: SecureHash.java,v 1.16 2002/09/24 23:02:46 eaton Exp $
Author:
Chris WElls

Method Summary
 byte[] bytes()
          Returns the bytes contained in this hash
 Object clone()
          This is the clone routine for Fragment.
 boolean equals(Object o)
          Compares this SecureHash with another hash, and returns true iff they are the same type of hash and have the same byte representation
 String fullString()
          Converts all bytes of this SecureHash to a human-readable String
 void hash(byte[] bytes)
          Hashes over the input bytes
 void hash(byte[] bytes, int offset, int len)
          Hashes over the input bytes, starting at offset, going for len
 void hash(QuickSerializable o)
          Hashes over a QuickSerializable object
 void hash(String str)
          Hashes over the bytes of the input String
 int hashCode()
          Calculates a Java hash code for this SecureHash object (typically by taking its lower order bytes)
 boolean isNull()
          Determines if this SecureHash is a NULL hash or not.
 SecureHash nullHash()
          Returns the implementation's NULL hash (typically all zeroes).
 int size()
          Return the number of bytes used in the representation of this hash (for example, SHA1 uses 20 bytes)
 String toString()
          Converts a few bytes of this SecureHash to a human-readable String
 boolean verify(QuickSerializable o)
          Verifies a QuickSerializable object
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface ostore.util.QuickSerializable
serialize
 

Method Detail

size

public int size()
Return the number of bytes used in the representation of this hash (for example, SHA1 uses 20 bytes)

Returns:
number of bytes used in the implementation

isNull

public boolean isNull()
Determines if this SecureHash is a NULL hash or not.

Returns:
true iff this Hash has a NULL value

nullHash

public SecureHash nullHash()
Returns the implementation's NULL hash (typically all zeroes).

Returns:
the implementation's null hash

bytes

public byte[] bytes()
Returns the bytes contained in this hash

Returns:
the bytes of this hash

equals

public boolean equals(Object o)
Compares this SecureHash with another hash, and returns true iff they are the same type of hash and have the same byte representation

Overrides:
equals in class Object
Parameters:
o - the object with which to compare this SecureHash
Returns:
true iff this and o contain the same byte values

hashCode

public int hashCode()
Calculates a Java hash code for this SecureHash object (typically by taking its lower order bytes)

Overrides:
hashCode in class Object
Returns:
the Java hash code for this SecureHash

hash

public void hash(byte[] bytes,
                 int offset,
                 int len)
Hashes over the input bytes, starting at offset, going for len

Parameters:
bytes - byte array over which to hash
offset - offset in bytes[] at which to begin hashing
len - number of bytes over which to hash

hash

public void hash(byte[] bytes)
Hashes over the input bytes

Parameters:
bytes - byte array over which to hash

hash

public void hash(QuickSerializable o)
Hashes over a QuickSerializable object

Parameters:
o - the object over which to hash

hash

public void hash(String str)
Hashes over the bytes of the input String

Parameters:
str - the String over which to hash

verify

public boolean verify(QuickSerializable o)
Verifies a QuickSerializable object

Parameters:
o - the object over which to hash
Returns:
true iff the input object hashes to a hash value equal to this hash value

toString

public String toString()
Converts a few bytes of this SecureHash to a human-readable String

Overrides:
toString in class Object
Returns:
human-readable String representation of this Hash

fullString

public String fullString()
Converts all bytes of this SecureHash to a human-readable String

Returns:
human-readable String representation of this Hash containing every nibble of this Hash's value

clone

public Object clone()
             throws CloneNotSupportedException
This is the clone routine for Fragment. It deeply clones a fragment (meaning that it copies all of the data, not just references).

CloneNotSupportedException