加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090326192413/http://developer.android.com:80/reference/java/security/MessageDigest.html
public abstract class

MessageDigest

extends MessageDigestSpi
java.lang.Object
   ↳ java.security.MessageDigestSpi
     ↳ java.security.MessageDigest

Summary

Protected Constructors
MessageDigest(String algorithm)
Public Methods
Object clone()
Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
byte[] digest()
Computes and returns the final hash value that the receiver represents.
byte[] digest(byte[] input)
int digest(byte[] buf, int offset, int len)
final String getAlgorithm()
Returns the standard Java Security name for the algorithm being used by the receiver.
final int getDigestLength()
Return the engine digest length in bytes.
static MessageDigest getInstance(String algorithm, String provider)
static MessageDigest getInstance(String algorithm)
static MessageDigest getInstance(String algorithm, Provider provider)
Returns a new MessageDigest which is capable of running the algorithm described by the argument.
final Provider getProvider()
Returns the Provider of the digest represented by the receiver.
static boolean isEqual(byte[] digesta, byte[] digestb)
Does a simply byte-per-byte compare of the two digests.
void reset()
Puts the receiver back in an initial state, such that it is ready to compute a new hash.
String toString()
Returns a string containing a concise, human-readable description of the receiver.
void update(byte[] input)
void update(byte arg0)
Includes the argument in the hash value computed by the receiver.
void update(byte[] input, int offset, int len)
final void update(ByteBuffer input)
[Expand]
Inherited Methods
From class java.security.MessageDigestSpi
From class java.lang.Object

Protected Constructors

protected MessageDigest (String algorithm)

Public Methods

public Object clone ()

Returns a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.

Classes which wish to support cloning must specify that they implement the Cloneable interface, since the implementation checks for this.

Returns
  • Object a shallow copy of this object.

public byte[] digest ()

Computes and returns the final hash value that the receiver represents. After the digest is computed the receiver is reset.

Returns
  • the hash the receiver computed
See Also

public byte[] digest (byte[] input)

public int digest (byte[] buf, int offset, int len)

public final String getAlgorithm ()

Returns the standard Java Security name for the algorithm being used by the receiver.

Returns
  • String the name of the algorithm

public final int getDigestLength ()

Return the engine digest length in bytes. Default is 0.

Returns
  • int the engine digest length in bytes

public static MessageDigest getInstance (String algorithm, String provider)

public static MessageDigest getInstance (String algorithm)

public static MessageDigest getInstance (String algorithm, Provider provider)

Returns a new MessageDigest which is capable of running the algorithm described by the argument. The result will be an instance of a subclass of MessageDigest which implements that algorithm.

Parameters
algorithm java.lang.String Name of the algorithm desired
provider Provider Provider which has to implement the algorithm
Returns
  • MessageDigest a concrete implementation for the algorithm desired.
Throws
NoSuchAlgorithmException If the algorithm cannot be found

public final Provider getProvider ()

Returns the Provider of the digest represented by the receiver.

Returns
  • Provider an instance of a subclass of java.security.Provider

public static boolean isEqual (byte[] digesta, byte[] digestb)

Does a simply byte-per-byte compare of the two digests.

Parameters
digesta One of the digests to compare
digestb The digest to compare to
Returns
  • true if the two hashes are equal false if the two hashes are not equal

public void reset ()

Puts the receiver back in an initial state, such that it is ready to compute a new hash.

public String toString ()

Returns a string containing a concise, human-readable description of the receiver.

Returns
  • a printable representation for the receiver.

public void update (byte[] input)

public void update (byte arg0)

Includes the argument in the hash value computed by the receiver.

Parameters
arg0 byte the byte to feed to the hash algorithm
See Also

public void update (byte[] input, int offset, int len)

public final void update (ByteBuffer input)