Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.security

Class MessageDigest

java.lang.Object
|
+--java.security.MessageDigestSpi
   |
   +--java.security.MessageDigest


public abstract class MessageDigest

extends MessageDigestSpi

Constructor Summary

MessageDigest(java.lang.String algorithm)

Creates a MessageDigest representing the specified algorithm.

Method Summary

java.lang.Objectclone()

Returns a clone of this class if supported.
byte[]digest()

Computes the digest of the stored data.
intdigest(byte[] , int offset, int len)

Computes the final digest of the stored bytes and returns them.
byte[]digest(byte[] )

Computes a final update using the input array of bytes, then computes a final digest and returns it.
java.lang.StringgetAlgorithm()

Gets the name of the algorithm currently used.
intgetDigestLength()

Gets the length of the message digest.
static java.security.MessageDigestgetInstance(java.lang.String algorithm)

Gets an instance of the MessageDigest class representing the specified digest.
static java.security.MessageDigestgetInstance(java.lang.String algorithm, java.lang.String provider)

Gets an instance of the MessageDigest class representing the specified digest from the specified provider.
java.security.ProvidergetProvider()

Gets the provider that the MessageDigest is from.
static booleanisEqual(byte[] , byte[] )

Does a simple byte comparison of the two digests.
voidreset()

Resets the message digest.
java.lang.StringtoString()

Returns a representation of the MessageDigest as a String.
voidupdate(byte input)

Updates the digest with the byte.
voidupdate(byte[] , int offset, int len)

Updates the digest with the bytes from the array from the specified offset to the specified length.
voidupdate(byte[] )

Updates the digest with the bytes from the array.

Constructor Details

MessageDigest

protected MessageDigest(java.lang.String algorithm)

Creates a MessageDigest representing the specified algorithm.

Parameters:


Method Details

clone

public Object clone()

Returns a clone of this class if supported. If it does not then it throws CloneNotSupportedException. The cloning of this class depends on whether the subclass MessageDigestSpi implements Cloneable which contains the actual implementation of the appropriate algorithm.

Returns:

Throws:


digest

public byte[] digest()

Computes the digest of the stored data.

Returns:


digest

public byte[] digest(byte[] )

Computes a final update using the input array of bytes, then computes a final digest and returns it. It calls update(input) and then digest();

Parameters:

Returns:


digest

public int digest(byte[] , int offset, int len)

Computes the final digest of the stored bytes and returns them.

Parameters:

Returns:


getAlgorithm

public final String getAlgorithm()

Gets the name of the algorithm currently used. The names of algorithms are usually SHA-1 or MD5.

Returns:


getDigestLength

public final int getDigestLength()

Gets the length of the message digest. The default is zero which means that this message digest does not implement this function.

Returns:


getInstance

public static MessageDigest getInstance(java.lang.String algorithm)

Gets an instance of the MessageDigest class representing the specified digest. If the algorithm is not found then, it throws NoSuchAlgorithmException.

Parameters:

Returns:

Throws:


getInstance

public static MessageDigest getInstance(java.lang.String algorithm, java.lang.String provider)

Gets an instance of the MessageDigest class representing the specified digest from the specified provider. If the algorithm is not found then, it throws NoSuchAlgorithmException. If the provider is not found, then it throws NoSuchProviderException.

Parameters:

Returns:

Throws:


getProvider

public final Provider getProvider()

Gets the provider that the MessageDigest is from.

Returns:


isEqual

public static boolean isEqual(byte[] , byte[] )

Does a simple byte comparison of the two digests.

Parameters:

Returns:


reset

public void reset()

Resets the message digest.


toString

public String toString()

Returns a representation of the MessageDigest as a String.

Returns:


update

public void update(byte input)

Updates the digest with the byte.

Parameters:


update

public void update(byte[] )

Updates the digest with the bytes from the array.

Parameters:


update

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

Updates the digest with the bytes from the array from the specified offset to the specified length.

Parameters: