|
Final | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Object
|
+--java.security.MessageDigestSpi
|
+--java.security.MessageDigest
This class provides the functionality of a digest algorithm, like MD5 or SHA. This class is is abstract and extends from MessageDigestSpi to be compatible with JDK, which does it for historical reasons (check the JDK's Javadoc files).
| Constructor Summary | |
|---|---|
protected |
MessageDigest(String algorithmName)
Create a new MessageDigest with its algorithm set to the argument. |
| Method Summary | |
|---|---|
Object |
clone()
Answers 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 answers the final hash value that the receiver represents. |
byte[] |
digest(byte[] bytesToHash)
Includes the bytes of the argument in the hash value computed by the receiver, and then computes the final digest value. |
int |
digest(byte[] buffer,
int offset,
int length)
Computes the digest and stores it into the buffer passed as parameter. |
String |
getAlgorithm()
Answers the standard Java Security name for the algorithm being used by the receiver. |
int |
getDigestLength()
Return the engine digest length in bytes. |
static MessageDigest |
getInstance(String algorithmName)
Answers a new MessageDigest which is capable of running the algorithm described by the argument. |
static MessageDigest |
getInstance(String algorithmName,
Provider provider)
Answers a new MessageDigest which is capable of running the algorithm described by the argument. |
static MessageDigest |
getInstance(String algorithmName,
String providerName)
Answers a new MessageDigest which is capable of running the algorithm described by the argument. |
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()
Answers a string containing a concise, human-readable description of the receiver. |
void |
update(byte byteToHash)
Includes the argument in the hash value computed by the receiver. |
void |
update(byte[] bytesToHash)
Includes the bytes of the argument in the hash value computed by the receiver. |
void |
update(byte[] bytesToHash,
int offset,
int count)
Includes a range of bytes from the first argument in the hash value computed by the receiver. |
| Methods inherited from class java.security.MessageDigestSpi |
|---|
engineDigest, engineDigest, engineGetDigestLength, engineReset, engineUpdate, engineUpdate |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected MessageDigest(String algorithmName)
algorithmName - java.lang.String
the algorithm that the receiver will represent| Method Detail |
public Object clone()
throws CloneNotSupportedException
Classes which wish to support cloning must specify that they implement the Cloneable interface, since the native implementation checks for this.
clone in class MessageDigestSpiCloneNotSupportedException - if the component does not implement the interface Cloneablepublic byte[] digest()
reset()public byte[] digest(byte[] bytesToHash)
bytesToHash - byte[]
the source array
update(byte),
update(byte[]),
update(byte[], int, int),
digest(),
digest(byte[]),
digest(byte[], int, int)public int digest(byte[] buffer,
int offset,
int length)
throws DigestException
buffer - byte[]
the array into which to store the digestoffset - the starting offset into the arraylength - the number of bytes available to store the digest
DigestException - If an error occursdigest(),
digest(byte[]),
digest(byte[], int, int)public final String getAlgorithm()
public final int getDigestLength()
public static MessageDigest getInstance(String algorithmName)
throws NoSuchAlgorithmException
algorithmName - java.lang.String Name of the algorithm desired
NoSuchAlgorithmException - If the algorithm cannot be foundpublic static MessageDigest getInstance(String algorithmName,
String providerName)
throws NoSuchAlgorithmException,
NoSuchProviderException
algorithmName - java.lang.String Name of the algorithm desiredproviderName - java.lang.String Name of the provider which has to implement the algorithm
NoSuchAlgorithmException - If the algorithm cannot be found
NoSuchProviderException - If the provider cannot be foundpublic static MessageDigest getInstance(String algorithmName,
Provider provider)
throws NoSuchAlgorithmException
provider - Provider Provider which has to implement the algorithm
NoSuchAlgorithmException - If the algorithm cannot be foundpublic final Provider getProvider()
public static boolean isEqual(byte[] digesta,
byte[] digestb)
digesta - One of the digests to comparedigestb - The digest to compare to
true
if the two hashes are equal
false
if the two hashes are not equalpublic void reset()
MessageDigest.Wrapper.engineReset()public String toString()
toString in class Objectpublic void update(byte[] bytesToHash)
bytesToHash - byte[]
the source arraypublic void update(byte[] bytesToHash,
int offset,
int count)
bytesToHash - byte[]
the source arrayoffset - the starting offset into the arraycount - the number of bytes to include in the hashpublic void update(byte byteToHash)
byteToHash - byte
the byte to feed to the hash algorithmreset()
|
Final | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||