Build 1.0_r1(from source)

java.security
Class MessageDigest

java.lang.Object
  extended by java.security.MessageDigestSpi
      extended by java.security.MessageDigest

public abstract class MessageDigest
extends MessageDigestSpi


Constructor Summary
protected MessageDigest(String algorithm)
           
 
Method Summary
 Object clone()
          Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
 byte[] digest()
          Computes and returns the final hash value that the receiver represents.
 byte[] digest(byte[] input)
           
 int digest(byte[] buf, int offset, int len)
           
 String getAlgorithm()
          Returns the standard Java Security name for the algorithm being used by the receiver.
 int getDigestLength()
          Return the engine digest length in bytes.
static MessageDigest getInstance(String algorithm)
           
static MessageDigest getInstance(String algorithm, Provider provider)
          Returns a new MessageDigest which is capable of running the algorithm described by the argument.
static MessageDigest getInstance(String algorithm, String provider)
           
 Provider getProvider()
          Returns the Provider of the digest represented by the receiver.
static boolean isEqual(byte[] digesta, byte[] digestb)
          Does a simply byte-per-byte compare of the two digests.
 void reset()
          Puts the receiver back in an initial state, such that it is ready to compute a new hash.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 void update(byte arg0)
          Includes the argument in the hash value computed by the receiver.
 void update(byte[] input)
           
 void update(byte[] input, int offset, int len)
           
 void update(ByteBuffer input)
           
 
Methods inherited from class java.security.MessageDigestSpi
engineDigest, engineDigest, engineGetDigestLength, engineReset, engineUpdate, engineUpdate, engineUpdate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageDigest

protected MessageDigest(String algorithm)
Method Detail

getInstance

public static MessageDigest getInstance(String algorithm)
                                 throws NoSuchAlgorithmException
Throws:
NoSuchAlgorithmException

getInstance

public static MessageDigest getInstance(String algorithm,
                                        String provider)
                                 throws NoSuchAlgorithmException,
                                        NoSuchProviderException
Throws:
NoSuchAlgorithmException
NoSuchProviderException

getInstance

public static MessageDigest getInstance(String algorithm,
                                        Provider provider)
                                 throws NoSuchAlgorithmException
Returns a new MessageDigest which is capable of running the algorithm described by the argument. The result will be an instance of a subclass of MessageDigest which implements that algorithm.

Parameters:
algorithm - java.lang.String Name of the algorithm desired
provider - Provider Provider which has to implement the algorithm
Returns:
MessageDigest a concrete implementation for the algorithm desired.
Throws:
NoSuchAlgorithmException - If the algorithm cannot be found

reset

public void reset()
Puts the receiver back in an initial state, such that it is ready to compute a new hash.


update

public void update(byte arg0)
Includes the argument in the hash value computed by the receiver.

Parameters:
arg0 - byte the byte to feed to the hash algorithm
See Also:
reset()

update

public void update(byte[] input,
                   int offset,
                   int len)

update

public void update(byte[] input)

digest

public byte[] digest()
Computes and returns the final hash value that the receiver represents. After the digest is computed the receiver is reset.

Returns:
the hash the receiver computed
See Also:
reset()

digest

public int digest(byte[] buf,
                  int offset,
                  int len)
           throws DigestException
Throws:
DigestException

digest

public byte[] digest(byte[] input)

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
a printable representation for the receiver.

isEqual

public static boolean isEqual(byte[] digesta,
                              byte[] digestb)
Does a simply byte-per-byte compare of the two digests.

Parameters:
digesta - One of the digests to compare
digestb - The digest to compare to
Returns:
true if the two hashes are equal false if the two hashes are not equal

getAlgorithm

public final String getAlgorithm()
Returns the standard Java Security name for the algorithm being used by the receiver.

Returns:
String the name of the algorithm

getProvider

public final Provider getProvider()
Returns the Provider of the digest represented by the receiver.

Returns:
Provider an instance of a subclass of java.security.Provider

getDigestLength

public final int getDigestLength()
Return the engine digest length in bytes. Default is 0.

Returns:
int the engine digest length in bytes

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: Object
Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.

Classes which wish to support cloning must specify that they implement the Cloneable interface, since the implementation checks for this.

Overrides:
clone in class MessageDigestSpi
Returns:
Object a shallow copy of this object.
Throws:
CloneNotSupportedException - if the receiver's class does not implement the interface Cloneable.

update

public final void update(ByteBuffer input)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature