• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: URGENT, calculating MD5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: URGENT, calculating MD5


  • Subject: Re: URGENT, calculating MD5
  • From: Mark Morris <email@hidden>
  • Date: Mon, 6 Mar 2006 14:44:13 -0600

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

  • Follow-Ups:
    • Re: URGENT, calculating MD5
      • From: Amedeo Mantica <email@hidden>
References: 
 >URGENT, calculating MD5 (From: Amedeo Mantica <email@hidden>)

  • Prev by Date: Re: URGENT, calculating MD5
  • Next by Date: Re: URGENT, calculating MD5
  • Previous by thread: Re: URGENT, calculating MD5
  • Next by thread: Re: URGENT, calculating MD5
  • Index(es):
    • Date
    • Thread