public static String md5(String target) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
byte[] bytes = messageDigest.digest(target.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;
}
Java,MD5
最新推荐文章于 2023-03-06 07:04:07 发布