public class MessageUtil { public static String md5(String msg) { String ret_msg = ""; try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] input = msg.getBytes(); byte[] output = md.digest(input); ret_msg = Base64.encodeBase64String(output); } catch (Exception e) { e.printStackTrace(); } return ret_msg; } public static void main(String[] args) { System.out.println(md5("123456")); } }