GeezerVison is showing docs.oracle.com — MessageDigest (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.security
Class MessageDigest
-
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
MessageDigest(String algorithm) |
Creates a message digest with the specified algorithm name.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
Object |
clone() |
Returns a clone if the implementation is cloneable.
|
byte[] |
digest() |
Completes the hash computation by performing final operations
such as padding.
|
byte[] |
digest(byte[] input) |
Performs a final update on the digest using the specified array
of bytes, then completes the digest computation.
|
int |
digest(byte[] buf,
int offset,
int len) |
Completes the hash computation by performing final operations
such as padding.
|
String |
getAlgorithm() |
Returns a string that identifies the algorithm, independent of
implementation details.
|
int |
getDigestLength() |
Returns the length of the digest in bytes, or 0 if this operation is
not supported by the provider and the implementation is not cloneable.
|
static MessageDigest |
getInstance(String algorithm) |
Returns a MessageDigest object that implements the specified digest
algorithm.
|
static MessageDigest |
getInstance(String algorithm,
Provider provider) |
Returns a MessageDigest object that implements the specified digest
algorithm.
|
static MessageDigest |
getInstance(String algorithm,
String provider) |
Returns a MessageDigest object that implements the specified digest
algorithm.
|
Provider |
getProvider() |
Returns the provider of this message digest object.
|
static boolean |
isEqual(byte[] digesta,
byte[] digestb) |
Compares two digests for equality.
|
void |
reset() |
Resets the digest for further use.
|
String |
toString() |
Returns a string representation of this message digest object.
|
void |
update(byte input) |
Updates the digest using the specified byte.
|
void |
update(byte[] input) |
Updates the digest using the specified array of bytes.
|
void |
update(byte[] input,
int offset,
int len) |
Updates the digest using the specified array of bytes, starting
at the specified offset.
|
void |
update(ByteBuffer input) |
Update the digest using the specified ByteBuffer.
|
-
-
Method Detail
-
update
public void update(byte[] input,
int offset,
int len)
Updates the digest using the specified array of bytes, starting
at the specified offset.
- Parameters:
input - the array of bytes.
offset - the offset to start from in the array of bytes.
len - the number of bytes to use, starting at
offset.
-
update
public final void update(ByteBuffer input)
Update the digest using the specified ByteBuffer. The digest is
updated using the input.remaining() bytes starting
at input.position().
Upon return, the buffer's position will be equal to its limit;
its limit will not have changed.
- Parameters:
input - the ByteBuffer
- Since:
- 1.5
-
digest
public int digest(byte[] buf,
int offset,
int len)
throws DigestException
Completes the hash computation by performing final operations
such as padding. The digest is reset after this call is made.
- Parameters:
buf - output buffer for the computed digest
offset - offset into the output buffer to begin storing the digest
len - number of bytes within buf allotted for the digest
- Returns:
- the number of bytes placed into
buf
- Throws:
DigestException - if an error occurs.
-
isEqual
public static boolean isEqual(byte[] digesta,
byte[] digestb)
Compares two digests for equality. Does a simple byte compare.
- Parameters:
digesta - one of the digests to compare.
digestb - the other digest to compare.
- Returns:
- true if the digests are equal, false otherwise.
-
getDigestLength
public final int getDigestLength()
Returns the length of the digest in bytes, or 0 if this operation is
not supported by the provider and the implementation is not cloneable.
- Returns:
- the digest length in bytes, or 0 if this operation is not
supported by the provider and the implementation is not cloneable.
- Since:
- 1.2
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|