public static String md5Encode(String psd) { try { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] bytes = digest.digest(psd.getBytes()); StringBuffer sb = new StringBuffer(); for (byte b : bytes) { int i = b & 0xff; String hexString = Integer.toHexString(i); if (hexString.length() < 2) { hexString = "0" + hexString; } sb.append(hexString); } return sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }