FTP Server

com.theorem.ftp
Class MD5

java.lang.Object
  |
  +--com.theorem.ftp.MD5

public class MD5
extends java.lang.Object

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();

Version:
1.1 April 23, 1999 Fixed peculiar error in update() for offsets
Author:
Michael Lecuyer .

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

MD5

public MD5()
MD5 initialization. Begins an MD5 operation, writing a new context.

Method Detail

update

public void update(byte[] input)
MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context.

Parameters:
input - byte array of data

update

public void update(byte[] input,
                   int offset,
                   int inputLen)
MD5 block update operation.

Parameters:
input - byte array of data
offset - offset into the array to start the digest calculation
inputLen - byte count to use in the calculation

digest

public byte[] digest()
MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context.

Returns:
the digest

toString

public java.lang.String toString()
Deliver the Message Digest as a HEX string.

Overrides:
toString in class java.lang.Object
Returns:
a hex representation of the MD5 digest.

FTP Server

Submit a bug report or feature request

Copyright 1998-2001 AXL Software. PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.