Java tutorial
//package com.java2s; import java.security.MessageDigest; public class Main { public static String md5(String value) { String result; try { MessageDigest md = MessageDigest.getInstance("md5"); result = byteToHexString(md.digest(value.getBytes("utf-8"))); return result; } catch (Exception e) { e.printStackTrace(); } return value; } public static String byteToHexString(byte[] b) { StringBuffer hexString = new StringBuffer(); for (int i = 0; i < b.length; i++) { String hex = Integer.toHexString(b[i] & 0xFF); if (hex.length() == 1) { hex = '0' + hex; } hexString.append(hex.toUpperCase()); } return hexString.toString(); } }