Here you can find the source of getHashMD5(String arg)
public static String getHashMD5(String arg)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getHashMD5(String arg) { return generateMD5Hash(arg); }//w w w . j av a 2 s . co m /** * Generates a MD5 Hash for the argument string. * * @param arg * @return */ public static String generateMD5Hash(String arg) { try { byte[] bytesOfMessage = arg.getBytes("UTF-8"); MessageDigest md; md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < thedigest.length; i++) { String hex = Integer.toHexString(0xff & thedigest[i]); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }