How to convert a string to Hexadecimal String using MD5(Message Digest 5) Algorithm


/**
 * @param string String to convert
 * @return hexadecimal string generated by using MD5 Algorithm
 */
public static String convertStringToMD5HexaDecimalString(String string)
{
 String result="";
 if(string!=null)
 {
 string = string.trim();
 if(string.length()>0)
 {
 try
 {
 byte[] data = string.getBytes();
 MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
 digest.update(data);
 data = digest.digest();
 BigInteger bi = new BigInteger(data).abs();
 result= bi.toString(36);
 }
 catch (Exception e)
 {
 if(e!=null)
 e.printStackTrace();
 }
 }
 }
 return result;
}

Advertisements

Tags: ,

About krishjlk

http://www.facebook.com/krishna.kanth.121

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: