All Packages Class Hierarchy This Package Previous Next Index
Class cryptix.security.MessageHash
java.lang.Object
|
+----cryptix.security.MessageHash
- public class MessageHash
- extends Object
This class represents the output from a message digest, in a form
where the type can be ascertained.
Copyright © 1995-1997
Systemics Ltd
on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.2 $
- Author:
- Systemics Ltd, David Hopwood
-
MessageHash(String, byte[])
- Constructs a MessageHash for the specified algorithm name.
-
equals(Object)
- Tests whether this object is equal to another object.
-
fromDigest(MessageDigest)
- Creates a MessageHash with the value found by calling the
digest()
method on md.
-
fromDigest(MessageDigest, byte[])
- Creates a MessageHash with the value found by calling the
digest(byte[])
method on md.
-
getAlgorithm()
- Returns the name of the algorithm associated with this hash.
-
hashCode()
-
-
length()
- Returns the hash length in bytes.
-
toByteArray()
- Returns the hash as a new byte array.
-
toString()
- Returns a big endian Hex string showing the value of the hash,
prefixed by the standard algorithm name and a colon.
MessageHash
public MessageHash(String algorithm,
byte hash[])
- Constructs a MessageHash for the specified algorithm name. The hash value
is a copy of the byte array hash.
- Parameters:
- algorithm - the name of the MessageDigest algorithm.
- hash - a byte array containing the hash.
- Throws: NullPointerException
- if algorithm == null || hash == null
fromDigest
public static MessageHash fromDigest(MessageDigest md)
- Creates a MessageHash with the value found by calling the
digest()
method on md. This causes md to be reset. It is equivalent to:
new MessageHash(md.name(), md.digest())
fromDigest
public static MessageHash fromDigest(MessageDigest md,
byte data[])
- Creates a MessageHash with the value found by calling the
digest(byte[])
method on md. This causes md to be reset. It is equivalent to:
new MessageHash(md.name(), md.digest(data))
getAlgorithm
public String getAlgorithm()
- Returns the name of the algorithm associated with this hash.
toByteArray
public final byte[] toByteArray()
- Returns the hash as a new byte array.
length
public final int length()
- Returns the hash length in bytes.
hashCode
public int hashCode()
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Tests whether this object is equal to another object.
Two MessageHash objects are equal iff they are for the same algorithm, and
have the same value as a sequence of bytes.
- Returns:
- true iff the objects are equal
- Overrides:
- equals in class Object
toString
public String toString()
- Returns a big endian Hex string showing the value of the hash,
prefixed by the standard algorithm name and a colon.
- Returns:
- a string representing the hash.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index