| java.lang.Object | ||
| ↳ | java.security.MessageDigestSpi | |
| ↳ | java.security.MessageDigest | |
Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence. The original arbitrary-length sequence is the message, and the fixed-length byte sequence is the digest or message digest.
The basic pattern to digest an InputStream looks like this:
 
  MessageDigest digester = MessageDigest.getInstance("MD5");
  byte[] bytes = new byte[8192];
  int byteCount;
  while ((byteCount = in.read(bytes)) > 0) {
    digester.update(bytes, 0, byteCount);
  }
  byte[] digest = digester.digest();
 
 That is, after creating or resetting a MessageDigest you should
 call update(byte[], int, int) for each block of input data, and then call digest()
 to get the final digest. Note that calling digest resets the MessageDigest.
 Advanced users who want partial digests should clone their MessageDigest before
 calling digest.
 
This class is not thread-safe.
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Constructs a new instance of  MessageDigestwith the name of
 the algorithm to use. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Computes and stores the final hash value for this  MessageDigest. | |||||||||||
| Computes and returns the final hash value for this  MessageDigest. | |||||||||||
| Performs the final update and then computes and returns the final hash
 value for this  MessageDigest. | |||||||||||
| Returns the name of the algorithm of this  MessageDigest. | |||||||||||
| Returns the engine digest length in bytes. | |||||||||||
| Returns a new instance of  MessageDigestthat utilizes the
 specified algorithm from the specified provider. | |||||||||||
| Returns a new instance of  MessageDigestthat utilizes the
 specified algorithm from the specified provider. | |||||||||||
| Returns a new instance of  MessageDigestthat utilizes the
 specified algorithm. | |||||||||||
| Returns the provider associated with this  MessageDigest. | |||||||||||
| Indicates whether to digest are equal by performing a simply
 byte-per-byte compare of the two digests. | |||||||||||
| Puts this  MessageDigestback in an initial state, such that it is
 ready to compute a one way hash value. | |||||||||||
| Returns a string containing a concise, human-readable description of this
  MessageDigestincluding the name of its algorithm. | |||||||||||
| Updates this  MessageDigestusing the giveninput. | |||||||||||
| Updates this  MessageDigestusing the givenbyte[]. | |||||||||||
| Updates this  MessageDigestusing the givenbyte. | |||||||||||
| Updates this  MessageDigestusing the givenbyte[]. | |||||||||||
| [Expand] Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|  From class
  java.security.MessageDigestSpi | |||||||||||
|  From class
  java.lang.Object | |||||||||||
Constructs a new instance of MessageDigest with the name of
 the algorithm to use.
| algorithm | the name of algorithm to use | 
|---|
Computes and stores the final hash value for this MessageDigest.
 After the digest is computed the receiver is reset.
| buf | the buffer to store the result | 
|---|---|
| offset | the index of the first byte in bufto store | 
| len | the number of bytes allocated for the digest | 
buf| DigestException | if an error occurs | 
|---|---|
| IllegalArgumentException | if offsetorlenare not valid in respect tobuf | 
Computes and returns the final hash value for this MessageDigest.
 After the digest is computed the receiver is reset.
Performs the final update and then computes and returns the final hash
 value for this MessageDigest. After the digest is computed the
 receiver is reset.
| input | the bytearray | 
|---|
Returns the name of the algorithm of this MessageDigest.
MessageDigest
Returns the engine digest length in bytes. If the implementation does not
 implement this function or is not an instance of Cloneable,
 0 is returned.
0
Returns a new instance of MessageDigest that utilizes the
 specified algorithm from the specified provider.
| algorithm | the name of the algorithm to use | 
|---|---|
| provider | the name of the provider | 
MessageDigest that utilizes the
         specified algorithm from the specified provider| NoSuchAlgorithmException | if the specified algorithm is not available | 
|---|---|
| NoSuchProviderException | if the specified provider is not available | 
| NullPointerException | if algorithmisnull | 
| IllegalArgumentException | if provider == null || provider.isEmpty() | 
Returns a new instance of MessageDigest that utilizes the
 specified algorithm from the specified provider. The
 provider supplied does not have to be registered.
| algorithm | the name of the algorithm to use | 
|---|---|
| provider | the provider | 
MessageDigest that utilizes the
         specified algorithm from the specified provider| NoSuchAlgorithmException | if the specified algorithm is not available | 
|---|---|
| NullPointerException | if algorithmisnull | 
| IllegalArgumentException | if provider == null | 
Returns a new instance of MessageDigest that utilizes the
 specified algorithm.
| algorithm | the name of the algorithm to use | 
|---|
MessageDigest that utilizes the
         specified algorithm| NoSuchAlgorithmException | if the specified algorithm is not available | 
|---|---|
| NullPointerException | if algorithmisnull | 
Returns the provider associated with this MessageDigest.
MessageDigest
Indicates whether to digest are equal by performing a simply byte-per-byte compare of the two digests.
| digesta | the first digest to be compared | 
|---|---|
| digestb | the second digest to be compared | 
true if the two hashes are equal, false otherwise
Puts this MessageDigest back in an initial state, such that it is
 ready to compute a one way hash value.
Returns a string containing a concise, human-readable description of this
 MessageDigest including the name of its algorithm.
MessageDigest
Updates this MessageDigest using the given input.
| input | the ByteBuffer | 
|---|
Updates this MessageDigest using the given byte[].
| input | the bytearray | 
|---|---|
| offset | the index of the first byte in inputto update from | 
| len | the number of bytes in inputto update from | 
| IllegalArgumentException | if offsetorlenare not valid in respect toinput | 
|---|
Updates this MessageDigest using the given byte.
| arg0 | the byteto update thisMessageDigestwith | 
|---|
Updates this MessageDigest using the given byte[].
| input | the bytearray | 
|---|
| NullPointerException | if inputisnull | 
|---|