|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.MessageDigest
public abstract class MessageDigest
A generic class for computing message digests. Instantiate a subclass to implement a particular message digest algorithm (e.g., MD5).
To use, call one or more update()
methods in sequence, then call computeCurrent()
. The result of the digest computation can then be obtained using the getDigestBits()
method.
The init()
method may be called to reset the digest to its initial state. The digestValid
field indicates whether the value of digestBits
is valid, that is, no calls to update()
or init()
have been made since the last call to computeCurrent()
.
Nested Class Summary | |
---|---|
class |
MessageDigest.MDState Class representing the current state of a message digest object. |
Field Summary | |
---|---|
protected AlgorithmIdentifier |
algID The algorithm identifier of this MessageDigest object. |
byte[] |
digestBits Deprecated. Use getDigestBits() instead. |
boolean |
digestValid Deprecated. Use isValid() instead. |
Constructor Summary | |
---|---|
protected |
MessageDigest() Creates a new message digest object. |
Method Summary | |
---|---|
abstract java.lang.String |
algName() Returns the algorithm name of this message digest. |
abstract int |
blockSize() Returns the blocksize of this instance. |
abstract java.lang.Object |
clone() Returns a clone of this message digest object. |
abstract void |
computeCurrent() Completes the hash computation, performing any necessary operations such as padding. |
byte[] |
computeDigest(byte[] source) Performs a complete digest operation on the given array of bytes. |
byte[] |
computeDigest(Streamable o) Performs a complete digest operation on the given Streamable object. |
abstract AlgorithmIdentifier |
getAlgID() Returns the algorithm identifier of this object. |
byte[] |
getDigestBits() Returns a copy of the current digest bytes. |
abstract int |
getDigestLength() Returns the length in bytes of the message digest. |
static MessageDigest |
getInstance(AlgorithmIdentifier algID) Creates an instance of MessageDigest using the specified algorithm identifier. |
protected abstract MessageDigest.MDState |
getState() Gets the state of this MessageDigest instance. |
abstract void |
init() Resets this message digest object to its initial state. |
boolean |
isEqual(byte[] otherDigest) Compares this digest to the specified digest for equality. |
boolean |
isValid() Returns true if this MessageDigest is in a valid state and its digest bits are usable; otherwise returns false . |
void |
setAlgID(AlgorithmIdentifier algID) Sets the AlgorithmIdentifier of this MessageDigest instance. |
protected abstract void |
setState(MessageDigest.MDState state) Sets the state of this MessageDigest instance. |
java.lang.String |
toString() Returns a string representation of this message digest object. |
void |
update(boolean aValue) Adds one byte to the data being digested, either 1 (if the given boolean value is true), or 0 (if the given boolean value is false). |
abstract void |
update(byte aValue) Adds the specifed byte to the data being digested. |
void |
update(byte[] input) Adds the specified array of bytes to the data being digested. |
void |
update(byte[] input, int off, int len) Adds the specified sequence of bytes to the data being digested. |
void |
update(java.io.InputStream in) Adds characters from the specified input stream to the data being digested, until end of stream is reached. |
void |
update(int aValue) Adds four bytes -- the big-endian representation of the specified int value -- to the data being digested. |
void |
update(int[] input) Adds the specified array of int values to the data being digested, using big-endian representation. |
void |
update(long aValue) Adds eight bytes -- the big-endian representation of the specified long value -- to the data being digested. |
void |
update(long[] input) Adds the specified array of long values to the data being digested, using big-endian representation. |
void |
update(short aValue) Adds two bytes -- the big-endian representation of the specified short value -- to the data being digested. |
void |
update(short[] input) Adds the specified array of short values to the data being digested, using big-endian representation. |
void |
update(java.lang.String input) Adds the characters of the specified string to the data being digested. |
void |
update(SymmetricKey key) Adds encoded representation of the symmetric key . |
void |
updateASCII(java.lang.String input) Adds the characters of the specified string to the data being digested. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public byte[] digestBits
getDigestBits()
instead.public boolean digestValid
isValid()
instead.digestBits
is valid.protected AlgorithmIdentifier algID
Constructor Detail |
---|
protected MessageDigest()
Method Detail |
---|
public void setAlgID(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
algID
- The AlgorithmIdentifier to use.AlgorithmIdentifierException
public abstract AlgorithmIdentifier getAlgID()
public abstract int blockSize()
public static MessageDigest getInstance(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
algID
- The AlgorithmIdentifier which will determine which concrete MessageDigest instance will be created.AlgorithmIdentifierException
public abstract void init()
public abstract void update(byte aValue)
public void update(boolean aValue)
public void update(short aValue)
public void update(int aValue)
public void update(long aValue)
public void update(byte[] input, int off, int len)
input
- the input arrayoff
- start position in the input arraylen
- the number of input array elements to add to the data being digestedpublic void update(byte[] input)
public void update(short[] input)
public void update(int[] input)
public void update(long[] input)
public void update(java.lang.String input)
Each character is treated as a 16-bit value, and is appended in big-endian order.
public void update(SymmetricKey key)
public void updateASCII(java.lang.String input)
Each character is treated as a ISO-Latin1 (8-bit) character.
public void update(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public abstract void computeCurrent()
getDigestBits()
.public byte[] getDigestBits()
public boolean isValid()
true
if this MessageDigest
is in a valid state and its digest bits are usable; otherwise returns false
.public byte[] computeDigest(byte[] source)
That is, first init()
is called, then the byte array is given to update
, then computeCurrent()
is called.
public byte[] computeDigest(Streamable o) throws java.io.IOException
That is, first init()
is called, then the Streamable object is given to update
, then computeCurrent()
is called.
java.io.IOException
public boolean isEqual(byte[] otherDigest)
public abstract java.lang.String algName()
public abstract int getDigestLength()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract java.lang.Object clone()
clone
in class java.lang.Object
protected abstract MessageDigest.MDState getState()
protected abstract void setState(MessageDigest.MDState state)
|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |