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;
}
Java MD5 32位加密
猜你喜欢
转载自blog.csdn.net/WeiHao0240/article/details/102939629
今日推荐
周排行