Re: URGENT, calculating MD5
Re: URGENT, calculating MD5
- Subject: Re: URGENT, calculating MD5
- From: Amedeo Mantica <email@hidden>
- Date: Mon, 6 Mar 2006 23:28:34 +0100
Hi, finally used this package:
Works great Amedeo
On 06/mar/06, at 21:44, Mark Morris wrote: 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 "[B@6afa2"
any help? Thanks Amedeo
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden