public class MD5Encoder {
/**
* MD5加密
* @param string
* @return
* @throws Exception
*/
public static String encode(String string) throws Exception {
byte[] hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
if ((b & 0xFF) < 0x10) {
hex.append("0");
}
hex.append(Integer.toHexString(b & 0xFF));
}
return hex.toString();
}
}
MD5 加密工具类
最新推荐文章于 2021-12-16 17:23:31 发布