Java tutorial
//package com.java2s; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String calculateMD5(String string, String encoding) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] array = md.digest(string.getBytes(Charset.forName(encoding))); StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (NoSuchAlgorithmException e) { } return null; } }