/**
* 对value进行hash处理
* @return hash处理结果
*/
public static String digest(String input){
int length = 32;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger no = new BigInteger(1, messageDigest);
String hash = no.toString(16);
while (hash.length() < length) {
hash = MessageFormat.format("0{0}", hash);
}
return hash;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
java使用MD5生成摘要
于 2022-11-21 16:58:52 首次发布