Do you know how to decrypt MD5?
Thanks
-Sharon
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Ashish Shrestha
Sent: Thursday, 19 July 2001 2:04 PM
To: [EMAIL PROTECTED]
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