|
FTP Server | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.theorem.ftp.MD5
This program uses the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
This is a translation of the original C languge code found in RFC 1321, but uses an interface more consistent with the Java MessageDigest class.
A summary of the Message-Digest algorithm from RFC 1321:
The algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given prespecified target message digest. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA.
Here's a code snippit showing the interactions.
private byte[] RecvBuf; // Received Packet buffer data. private byte[] Authenticator; // Authenticator block for Access Request private String Secret; // Shared secret password
MD5 md = new MD5();
md.update(RecvBuf, 0, 4); // Header of the received packet md.update(Authenticator); // Request authenticator md.update(Secret.getBytes()); // Secret
byte md5bytes[] = md.digest();
| Constructor Summary | |
MD5()
MD5 initialization. |
|
| Method Summary | |
byte[] |
digest()
MD5 finalization. |
java.lang.String |
toString()
Deliver the Message Digest as a HEX string. |
void |
update(byte[] input)
MD5 block update operation. |
void |
update(byte[] input,
int offset,
int inputLen)
MD5 block update operation. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public MD5()
| Method Detail |
public void update(byte[] input)
input - byte array of data
public void update(byte[] input,
int offset,
int inputLen)
input - byte array of dataoffset - offset into the array to start the digest calculationinputLen - byte count to use in the calculationpublic byte[] digest()
public java.lang.String toString()
toString in class java.lang.Object
|
FTP Server | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||