3 回答

侃侃无极
TA贡献2051条经验 获得超10个赞
java.security.MessageDigest
是你的朋友。打电话getInstance("MD5")
若要获得您可以使用的MD5消息摘要,请执行以下操作。

慕容708150
TA贡献1831条经验 获得超4个赞
如果您实际上希望将答案作为字符串(而不是字节数组)返回,则始终可以执行如下操作:
String plaintext = "your text here";
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
hashtext = "0"+hashtext;
}
添加回答
举报
0/150
提交
取消