Here you can find the source of md5(String string)
public static String md5(String string)
//package com.java2s; //License from project: Open Source License import java.security.NoSuchAlgorithmException; import java.security.MessageDigest; import java.io.UnsupportedEncodingException; import java.math.BigInteger; public class Main { public static String md5(String string) { try {/* w ww . j a v a2s .co m*/ byte[] bytesOfMessage = string.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digest = md.digest(bytesOfMessage); return byteArrayToString(digest); } catch (NoSuchAlgorithmException nsae) { throw new RuntimeException("No HMac SHA256 algorithm"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("No UTF-8"); } } public static String byteArrayToString(byte[] data) { BigInteger bigInteger = new BigInteger(1, data); String hash = bigInteger.toString(16); while (hash.length() < 32) { hash = "0" + hash; } return hash; } }