java利用MD5加密简单方法

public static String md5(String pwd) {

String md5Pwd = "";

               String uuid = UUID.randomUUID().toString().replace("-", "");

try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bs = md.digest(pwd.getBytes());
for (byte b : bs) {
int x = (b + uuid.hashCode()) & 0xff;
String hex = Integer.toHexString(x);
if (hex.length() == 1) {
hex += "0";
}
newPwd += hex;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return newPwd;
}

猜你喜欢

转载自blog.csdn.net/m0_37934074/article/details/79570641