java.security
Class MessageDigest
java.lang.Object
|
+--java.security.MessageDigestSpi
|
+--java.security.MessageDigest
MessageDigest
protected MessageDigest(java.lang.String algorithm)
Creates a MessageDigest representing the specified
algorithm.
Parameters:
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:
- a byte array representing the message digest
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:
- a byte array representing the message digest
digest
public int digest(byte[] , int offset, int len)
Computes the final digest of the stored bytes and returns
them.
Parameters:
Returns:
- Returns the length of the buffer
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:
- length of the message digest
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:
- a MessageDigest representing the desired algorithm
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:
- a MessageDigest representing the desired algorithm
Throws:
getProvider
public final Provider getProvider()
Gets the provider that the MessageDigest is from.
Returns:
- the provider the this MessageDigest
isEqual
public static boolean isEqual(byte[] , byte[] )
Does a simple byte comparison of the two digests.
Parameters:
Returns:
- true if they are equal, false otherwise
reset
public void reset()
Resets the message digest.
toString
public String toString()
Returns a representation of the MessageDigest as a String.
Returns:
- a string representing the message digest
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: