# Document Authentication using java.security.MessageDigest class.

Barclay Clibborn (barclay@clibborn.com)
Mon, 22 Feb 1999 13:21:58 -0000

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Peter Vennel: "signed applet example 1.2"
- Previous message: Wolfgang Korn: "Keytool and RSA problem"

    From: Barclay Clibborn <barclay@clibborn.com>

    To: "'java-security@java.sun.com'" <java-security@java.sun.com>

    Subject: Document Authentication using java.security.MessageDigest class.

    Date: Mon, 22 Feb 1999 13:21:58 -0000

Dear Sir/Madam,

I a final year Computer Science student studying in University College
Cork, Ireland (http://www.cs.ucc.ie) and have undertaken a security project
that provides a document authentication service.

Each client submits an MD5 object
(java.security.MessageDigest.getInstance("MD5")) which represents an MD5
hash of their document they want notarised (ie : a certificate proving both
the age and content of the document). Everything in the project is going
well apart from working with the MD5 objects.

The MessageDigest class stores the encrypted data in byte form. Each
certificate that is sent back to a client must contain a String
representation of the MD5 hash - our problem is inter-converting between
byte and string representations. Basically, at the end of a time period, we
store string reps of the MD5 objects. At a later time period, might be
days, weeks, months later, we need those MD5 objects again - so, we try to
re-construct them from their string reps.

We need to be able to RE-construct an MD5 object from its previous String
representation.

Unfortunately, this just isn't happening for us !

Our toString method for this MD5 class is as follows:

public String toString()
{
StringBuffer sb = new StringBuffer();
byte[] buffer = getHashValue();
int x = buffer.length;

for( int i = 0 ; i < x ; i++ )
{
int val = (int)buffer[i];
sb.append( Integer.toString( ( val >> 4 ) & 0xF, 16 ) );
sb.append( Integer.toString( val & 0xF, 16 ) );
}
String str = new String(sb);
return( str );
}

Any ideas on how to be able to re-construct the original MD5 object from
the resulting string from the above toString method, would be very much
appreciated.

Regards,

Barclay.

- Next message: Peter Vennel: "signed applet example 1.2"
- Previous message: Wolfgang Korn: "Keytool and RSA problem"