Re: URGENT, calculating MD5
Re: URGENT, calculating MD5
- Subject: Re: URGENT, calculating MD5
- From: Timo Hoepfner <email@hidden>
- Date: Tue, 7 Mar 2006 18:07:11 +0100
Hi,
AFAIK java's arrays don't override java.lang.Object's toString()
method, so you get a textual representation of the internal object
ID. To get a String from an array of bytes you should use the
public String(byte[] bytes)
constructor. So try
String calculatedMd5 = new String(result);
instead of result.toString().
HTH,
Timo
Am 06.03.2006 um 21:31 schrieb Amedeo Mantica:
my function:
String calculateMd5 (String message)
{
MessageDigest myMAC = MessageDigest.getInstance("MD5");
byte[] messageBytes=message.getBytes();
myMAC.update(messageBytes);
byte[] result = myMAC.digest();
String calculatedMd5=result.toString();
return calculatedMd5;
}
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:
40onlinehome.de
This email sent to email@hidden
_______________________________________________
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