|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.motorola.iden.security.MessageDigestSpi | +--com.motorola.iden.security.MessageDigest
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
methods. At any point reset
can be called
to reset the digest. Once all the data to be updated has been
updated, one of the digest
methods 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.
MessageDigest md; try { md = MessageDigest.getInstance("MD5"); md.update(toChapter1); md.update(toChapter2); byte[] toChapter1Digest = md.digest(); etc. } catch (NoSuchAlgorithmException) {}
Note that this class is abstract and extends from
MessageDigestSpi
for historical reasons.
Application developers should only take notice of the methods defined in
this MessageDigest
class; all the methods in
the superclass are intended for cryptographic service providers who wish to
supply their own implementations of message digest algorithms.
[MessageDigestSpi]
Constructor Summary | |
MessageDigest()
|
Method Summary | |
byte[] |
digest()
Completes the hash computation by performing final operations such as padding. |
java.lang.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(java.lang.String algorithm)
Generates a MessageDigest object that implements the specified digest algorithm. |
static MessageDigest |
getInstance(java.lang.String algorithm,
java.lang.String usrPackage)
Generates a MessageDigest object that implements the specified digest algorithm. |
void |
reset()
Resets the digest for further use. |
void |
update(byte input)
Updates the digest using the specified byte. |
void |
update(byte[] input,
int offset,
int len)
Updates the digest using the specified array of bytes, starting at the specified offset. |
Methods inherited from class com.motorola.iden.security.MessageDigestSpi |
engineDigest, engineGetDigestLength, engineReset, engineUpdate, engineUpdate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MessageDigest()
Method Detail |
public static MessageDigest getInstance(java.lang.String algorithm) throws NoSuchAlgorithmException
If the default provider package provides an implementation of the requested digest algorithm, an instance of MessageDigest containing that implementation is returned. If the algorithm is not available in the default package, NoSuchAlgorithmException would be thrown.
algorithm
- the name of the algorithm requested.
MD5 and SHA are supported in current implementation.NoSuchAlgorithmException
- if the algorithm is not available in the default package.public static MessageDigest getInstance(java.lang.String algorithm, java.lang.String usrPackage) throws NoSuchAlgorithmException
If the default provider package provides an implementation of the requested digest algorithm, an instance of MessageDigest containing that implementation is returned. If the algorithm is not available in the default package, other packages are searched.
algorithm
- the name of the algorithm requested.
MD5 and SHA are supported in current implementation.usrPackage
- the package which the end user provided algorithm belongs to.NoSuchAlgorithmException
- if the algorithm is
not available in usrPackage..public void update(byte input)
input
- the byte with which to update the digest.public void update(byte[] input, int offset, int len)
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
.public byte[] digest()
public void reset()
public final java.lang.String getAlgorithm()
public final int getDigestLength()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |