Here you can find the source of md5(String string)
public static String md5(String string)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String string) { StringBuffer sb = new StringBuffer(); try {/*ww w .ja va2 s .co m*/ byte[] buf = string.getBytes(); MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(buf); byte[] digestBuf = md5.digest(); for (byte b : digestBuf) { sb.append(Integer.toHexString(b & 0xff)); } } catch (NoSuchAlgorithmException e) { /*empty*/ } return sb.toString(); } }