Dear Ashish,

Where do I get the MessageDigest Class from?

Thanx,
Hardeep

----- Original Message -----
From: "Ashish Shrestha" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 19, 2001 9:33 AM
Subject: MD5 example


> Dear Hardeep,
>
> I have included an example of MD5 for you.
> If you want to use the 16 byte data instead of convert it to hex string
> just return the md5.digest().
>
> Hope this helps.
>
> Ashish
> http://headlines.sourceforge.net
>
>         /**
>                 Generate a MD5 digest and return as hex.
>
>                 @param s String for which MD5 is to be generated.
>                 @returns 32 character hex representation of the MD5
> digest.
>         */
>         public static  String md5Hex(String s)
>                 throws NoSuchAlgorithmException{
>
>                 MessageDigest md5 = MessageDigest.getInstance("MD5");
>                 md5.update(s.getBytes());
>
>                 return bytesToHexString(md5.digest());
>         }
>
>         public static String bytesToHexString(byte[] b){
>                 char[] hexChars = {'0','1','2','3','4','5','6','7',
>                         '8','9','A','B','C','D','E','F'};
>
>                 StringBuffer hexString = new StringBuffer();
>
>                 for (int i = 0; i < b.length; i++){
>                         hexString.append(hexChars[(b[i] >> 4) & 0x0f]);
>                         hexString.append(hexChars[b[i] & 0x0f]);
>                 }
>
>                 return hexString.toString();
>         }
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to