Skip to content

Most visited

Recently visited

navigation
Added in API level 1

MessageDigestSpi

public abstract class MessageDigestSpi
extends Object

java.lang.Object
   ↳ java.security.MessageDigestSpi
Known Direct Subclasses


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:

Summary

Public constructors

MessageDigestSpi()

Public methods

Object clone()

Creates and returns a copy of this Object.

Protected methods

abstract byte[] engineDigest()

Computes and returns the final hash value for this MessageDigestSpi.

int engineDigest(byte[] buf, int offset, int len)

Computes and stores the final hash value for this MessageDigestSpi.

int engineGetDigestLength()

Returns the engine digest length in bytes.

abstract void engineReset()

Puts this MessageDigestSpi back in an initial state, such that it is ready to compute a one way hash value.

abstract void engineUpdate(byte[] input, int offset, int len)

Updates this MessageDigestSpi using the given byte[].

abstract void engineUpdate(byte input)

Updates this MessageDigestSpi using the given byte.

void engineUpdate(ByteBuffer input)

Updates this MessageDigestSpi using the given input.

Inherited methods

From class java.lang.Object

Public constructors

MessageDigestSpi

Added in API level 1
MessageDigestSpi ()

Public methods

clone

Added in API level 1
Object clone ()

Creates and returns a copy of this 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.

Returns
Object a copy of this object.
Throws
CloneNotSupportedException

Protected methods

engineDigest

Added in API level 1
byte[] engineDigest ()

Computes and returns the final hash value for this MessageDigestSpi. After the digest is computed the receiver is reset.

Returns
byte[] the computed one way hash value.

See also:

engineDigest

Added in API level 1
int engineDigest (byte[] buf, 
                int offset, 
                int len)

Computes and stores the final hash value for this MessageDigestSpi. After the digest is computed the receiver is reset.

Parameters
buf byte: the buffer to store the result in.
offset int: the index of the first byte in buf to store in.
len int: the number of bytes allocated for the digest.
Returns
int the number of bytes written to buf.
Throws
DigestException if an error occures.
IllegalArgumentException if offset or len are not valid in respect to buf.

See also:

engineGetDigestLength

Added in API level 1
int engineGetDigestLength ()

Returns the engine digest length in bytes. If the implementation does not implement this function 0 is returned.

Returns
int the digest length in bytes, or 0.

engineReset

Added in API level 1
void engineReset ()

Puts this MessageDigestSpi back in an initial state, such that it is ready to compute a one way hash value.

engineUpdate

Added in API level 1
void engineUpdate (byte[] input, 
                int offset, 
                int len)

Updates this MessageDigestSpi using the given byte[].

Parameters
input byte: the byte array.
offset int: the index of the first byte in input to update from.
len int: the number of bytes in input to update from.
Throws
IllegalArgumentException if offset or len are not valid in respect to input.

engineUpdate

Added in API level 1
void engineUpdate (byte input)

Updates this MessageDigestSpi using the given byte.

Parameters
input byte: the byte to update this MessageDigestSpi with.

See also:

engineUpdate

Added in API level 1
void engineUpdate (ByteBuffer input)

Updates this MessageDigestSpi using the given input.

Parameters
input ByteBuffer: the ByteBuffer.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.