public static String md5(String plaintext) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plaintext.getBytes());
byte bytes[] = md.digest();

int c;

StringBuffer buf = new StringBuffer("");
for (int index = 0; index < bytes.length; index++) {
c = bytes[index];
if (c < 0){
c += 256;
}
if (c < 16){
buf.append("0");
}
buf.append(Integer.toHexString(c));
}
return buf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}