Package java.security
Class MessageDigestSpi
java.lang.Object
java.security.MessageDigestSpi
- Direct Known Subclasses:
MessageDigest,SHA1_MessageDigestImpl
public abstract class MessageDigestSpi extends Object
MessageDigestSpi is the Service Provider Interface (SPI) definition
for MessageDigest. Examples of digest algorithms are MD5 and SHA. A
digest is a secure one way hash function for a stream of bytes. It acts like
a fingerprint for a stream of bytes.- See Also:
MessageDigest
-
Constructor Summary
Constructors Constructor Description MessageDigestSpi() -
Method Summary
Modifier and Type Method Description Objectclone()Creates and returns a copy of thisObject.protected abstract byte[]engineDigest()Computes and returns the final hash value for thisMessageDigestSpi.protected intengineDigest(byte[] buf, int offset, int len)Computes and stores the final hash value for thisMessageDigestSpi.protected intengineGetDigestLength()Returns the engine digest length in bytes.protected abstract voidengineReset()Puts thisMessageDigestSpiback in an initial state, such that it is ready to compute a one way hash value.protected abstract voidengineUpdate(byte input)Updates thisMessageDigestSpiusing the givenbyte.protected abstract voidengineUpdate(byte[] input, int offset, int len)Updates thisMessageDigestSpiusing the givenbyte[].protected voidengineUpdate(ByteBuffer input)Updates thisMessageDigestSpiusing the giveninput.
-
Constructor Details
-
MessageDigestSpi
public MessageDigestSpi()
-
-
Method Details
-
engineGetDigestLength
protected int engineGetDigestLength()Returns the engine digest length in bytes. If the implementation does not implement this function0is returned.- Returns:
- the digest length in bytes, or
0.
-
engineUpdate
protected abstract void engineUpdate(byte input)Updates thisMessageDigestSpiusing the givenbyte.- Parameters:
input- thebyteto update thisMessageDigestSpiwith.- See Also:
engineReset()
-
engineUpdate
protected abstract void engineUpdate(byte[] input, int offset, int len)Updates thisMessageDigestSpiusing the givenbyte[].- Parameters:
input- thebytearray.offset- the index of the first byte ininputto update from.len- the number of bytes ininputto update from.- Throws:
IllegalArgumentException- ifoffsetorlenare not valid in respect toinput.
-
engineUpdate
Updates thisMessageDigestSpiusing the giveninput.- Parameters:
input- theByteBuffer.
-
engineDigest
protected abstract byte[] engineDigest()Computes and returns the final hash value for thisMessageDigestSpi. After the digest is computed the receiver is reset.- Returns:
- the computed one way hash value.
- See Also:
engineReset()
-
engineDigest
Computes and stores the final hash value for thisMessageDigestSpi. After the digest is computed the receiver is reset.- Parameters:
buf- the buffer to store the result in.offset- the index of the first byte inbufto store in.len- the number of bytes allocated for the digest.- Returns:
- the number of bytes written to
buf. - Throws:
DigestException- if an error occures.IllegalArgumentException- ifoffsetorlenare not valid in respect tobuf.- See Also:
engineReset()
-
engineReset
protected abstract void engineReset()Puts thisMessageDigestSpiback in an initial state, such that it is ready to compute a one way hash value. -
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects.- Overrides:
clonein classObject- Returns:
- a copy of this object.
- Throws:
CloneNotSupportedException- if this object's class does not implement theCloneableinterface.
-