import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MySecurity {
public static String MD5(byte[] b) {
byte[] md5b = null;
char[] digest = "0123456789abcdef".toCharArray();
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
md5b = md.digest(b);
char[] c = new char[32];
int k = 0;
for (int i = 0; i < 16; i++) {
byte b1 = md5b[i];
c[k++] = digest[(b1 & 0xf0) >> 4];
c[k++] = digest[b1 & 0xf];
}
return new String(c);
}
public static void main(String[] args) {
String s = "a";
System.out.println(s);
System.out.print(MD5(s.getBytes()));
}
}