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

Constructor Index

 o MessageHash(String, byte[])
Constructs a MessageHash for the specified algorithm name.

Method Index

 o equals(Object)
Tests whether this object is equal to another object.
 o fromDigest(MessageDigest)
Creates a MessageHash with the value found by calling the digest() method on md.
 o fromDigest(MessageDigest, byte[])
Creates a MessageHash with the value found by calling the digest(byte[]) method on md.
 o getAlgorithm()
Returns the name of the algorithm associated with this hash.
 o hashCode()
 o length()
Returns the hash length in bytes.
 o toByteArray()
Returns the hash as a new byte array.
 o toString()
Returns a big endian Hex string showing the value of the hash, prefixed by the standard algorithm name and a colon.

Constructors

 o 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

Methods

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

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

 o getAlgorithm
 public String getAlgorithm()
Returns the name of the algorithm associated with this hash.

 o toByteArray
 public final byte[] toByteArray()
Returns the hash as a new byte array.

 o length
 public final int length()
Returns the hash length in bytes.

 o hashCode
 public int hashCode()
Overrides:
hashCode in class Object
 o 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
 o 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