Java tutorial
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; public class Main { private static final char LOWER_HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; private static final char CAPITAL_HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String passwordEncoder(String params) { StringBuilder param = new StringBuilder(params); param.append("&@*#^%^%$&"); char[] md5 = md5Encoder(param.toString(), false).toCharArray(); if (md5.length == 32) { param.append(md5[5]).append(md5[1]).append(md5[11]).append(md5[8]).append(md5[18]).append(md5[30]) .append(md5[28]).append(md5[22]); } return md5Encoder(param.toString(), false); } public static String md5Encoder(String content, boolean isCapital) { try { byte[] strTemp = content.getBytes(); MessageDigest mdTemp = MessageDigest.getInstance("MD5"); mdTemp.update(strTemp); byte[] mds = mdTemp.digest(); int j = mds.length; char str[] = new char[j * 2]; int k = 0; for (byte md : mds) { if (isCapital) { str[k++] = CAPITAL_HEX_DIGITS[md >> 4 & 0xf]; str[k++] = CAPITAL_HEX_DIGITS[md & 0xf]; } else { str[k++] = LOWER_HEX_DIGITS[md >> 4 & 0xf]; str[k++] = LOWER_HEX_DIGITS[md & 0xf]; } } return new String(str); } catch (Exception e) { return ""; } } }