1.javaä¸md5å å¯
javaä¸md5å å¯
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class md5 {
public String str;
public void md5s(String plainText) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += ;
if (i < )
buf.append("0");
buf.append(Integer.toHexString(i));
}
str = buf.toString();
System.out.println("result: " + buf.toString());// ä½çå å¯
System.out.println("result: " + buf.toString().substring(8,加密文档源码推荐 ));// ä½çå å¯
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String agrs[]) {
md5 md = new md5();
md.md5s("4");//å å¯4
}
}
2024-11-23 13:10
2024-11-23 13:08
2024-11-23 13:05
2024-11-23 12:26
2024-11-23 12:18
2024-11-23 12:12
2024-11-23 11:32
2024-11-23 11:16