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.MessageDigest
Constructor and Description |
---|
MessageDigestSpi() |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates and returns a copy of this
Object . |
protected abstract byte[] |
engineDigest()
Computes and returns the final hash value for this
MessageDigestSpi . |
protected int |
engineDigest(byte[] buf,
int offset,
int len)
Computes and stores the final hash value for this
MessageDigestSpi . |
protected int |
engineGetDigestLength()
Returns the engine digest length in bytes.
|
protected abstract void |
engineReset()
Puts this
MessageDigestSpi back in an initial state, such that it
is ready to compute a one way hash value. |
protected abstract void |
engineUpdate(byte input)
Updates this
MessageDigestSpi using the given byte . |
protected abstract void |
engineUpdate(byte[] input,
int offset,
int len)
Updates this
MessageDigestSpi using the given byte[] . |
protected void |
engineUpdate(ByteBuffer input)
Updates this
MessageDigestSpi using the given input . |
protected int engineGetDigestLength()
0
is returned.0
.protected abstract void engineUpdate(byte input)
MessageDigestSpi
using the given byte
.input
- the byte
to update this MessageDigestSpi
with.engineReset()
protected abstract void engineUpdate(byte[] input, int offset, int len)
MessageDigestSpi
using the given byte[]
.input
- the byte
array.offset
- the index of the first byte in input
to update from.len
- the number of bytes in input
to update from.IllegalArgumentException
- if offset
or len
are not valid in respect to
input
.protected void engineUpdate(ByteBuffer input)
MessageDigestSpi
using the given input
.input
- the ByteBuffer
.protected abstract byte[] engineDigest()
MessageDigestSpi
. After the digest is computed the receiver is
reset.engineReset()
protected int engineDigest(byte[] buf, int offset, int len) throws DigestException
MessageDigestSpi
. After the digest is computed the receiver is
reset.buf
- the buffer to store the result in.offset
- the index of the first byte in buf
to store in.len
- the number of bytes allocated for the digest.buf
.DigestException
- if an error occures.IllegalArgumentException
- if offset
or len
are not valid in respect to
buf
.engineReset()
protected abstract void engineReset()
MessageDigestSpi
back in an initial state, such that it
is ready to compute a one way hash value.public Object clone() throws CloneNotSupportedException
Object
Object
. 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 call super.clone()
to create the new instance and then create deep copies of the nested,
mutable objects.clone
in class Object
CloneNotSupportedException
- if this object's class does not implement the Cloneable
interface.