public class MD5Utils {
public static String md5(String string) {
StringBuffer sb = new StringBuffer();
try {
MessageDigest instance = MessageDigest.getInstance("MD5");
instance.update(string.getBytes());
byte[] digest = instance.digest();
for (byte b : digest) {
int g = b & 0xff;
String hexString = Integer.toHexString(g);
if (hexString.length() < 2) {
hexString = "0" + hexString;
}
sb.append(hexString);
}
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sb.toString();
}
MD5加密
最新推荐文章于 2022-12-28 13:50:25 发布