MessageDigestpublic abstract class MessageDigest extends Object This MessageDigest class provides applications the functionality of a
message digest algorithm, such as MD5 or SHA.
Message digests are secure one-way hash functions that take arbitrary-sized
data and output a fixed-length hash value.
A MessageDigest object starts out initialized. The data is
processed through it using the update
method. At any point {@link #reset() reset} can be called
to reset the digest. Once all the data to be updated has been
updated, the digest method should
be called to complete the hash computation.
The digest method can be called once for a given number
of updates. After digest has been called,
the MessageDigest
object is reset to its initialized state. |
Fields Summary |
---|
com.sun.midp.crypto.MessageDigest | messageDigestMessage digest implementation. |
Constructors Summary |
---|
MessageDigest(String algorithm)Creates a message digest with the specified algorithm name.
|
Methods Summary |
---|
public int | digest(byte[] buf, int offset, int len)Completes the hash computation by performing final operations
such as padding. The digest is reset after this call is made.
try {
return messageDigest.digest(buf, offset, len);
} catch (com.sun.midp.crypto.DigestException e) {
throw new DigestException(e.getMessage());
}
| public static java.security.MessageDigest | getInstance(java.lang.String algorithm)Generates a MessageDigest object that implements
the specified digest
algorithm.
try {
return new MessageDigestImpl(algorithm,
com.sun.midp.crypto.MessageDigest.getInstance(algorithm));
} catch (com.sun.midp.crypto.NoSuchAlgorithmException e) {
throw new NoSuchAlgorithmException(e.getMessage());
}
| public void | reset()Resets the digest for further use.
messageDigest.reset();
| public void | update(byte[] input, int offset, int len)Updates the digest using the specified array of bytes, starting
at the specified offset.
messageDigest.update(input, offset, len);
|
|