Hello Amedeo,

I don't think there's going to be anything that keeps the bytes of the hash in the printable range of characters, if that's where your concern lies.

What I do, solely for the purposes of storing to the database, is take the easy way out and convert to a string representation of the hex values.  This is not the most space efficient, to be sure, but it's straightforward.  See my modification of your code below.  (You could certainly write a method that goes in the opposite direction, from hex-in-a-string to actual bytes.)

Regards,
Mark

On Mar 6, 2006, at 2:31 PM, Amedeo Mantica wrote:

my function:

String calculateMd5Hex (String message)
{
MessageDigest myMAC = MessageDigest.getInstance("MD5");

byte[] messageBytes=message.getBytes();
myMAC.update(messageBytes);
byte[] result = myMAC.digest();

   BASE64Encoder encode = new BASE64Encoder();
   String calculatedMd5Hex = encode.encodeBuffer( result );

// String calculatedMd5=result.toString();
// return calculatedMd5;



   return calculatedMd5Hex;

}

I ALWAYS GOT A STRING LIKE  "[EMAIL PROTECTED]"

any help?
Thanks
Amedeo

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to