Java tutorial
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String encryption(String plainText) { String re_md5 = ""; try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(plainText.getBytes()); byte b[] = md.digest(); int i = 0; StringBuilder sb = new StringBuilder(""); for (int offset = 0, len = b.length; offset < len; offset++) { i = b[offset]; if (i < 0) { i += 256; } if (i < 16) { sb.append("0"); } sb.append(Integer.toHexString(i)); } re_md5 = sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return re_md5; } }