Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getMd5Digest(String pInput) { if (pInput == null) return ""; try { MessageDigest lDigest = MessageDigest.getInstance("MD5"); lDigest.update(getBytes(pInput)); BigInteger lHashInt = new BigInteger(1, lDigest.digest()); return String.format("%1$032X", lHashInt); } catch (NoSuchAlgorithmException lException) { throw new RuntimeException(lException); } } private static byte[] getBytes(String s) { try { return s.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { return s.getBytes(); } } }