java中16位或32位MD5加密原⽂链接:blog.csdn/u010197591/article/details/51483559  (侵删)
import java.security.MessageDigest;
public class MD5Helper {
public static String encrypt32(String encryptStr) {
MessageDigest md5;
try {
md5 = Instance("MD5");
byte[] md5Bytes = md5.Bytes());
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16)
hexValue.append("0");
hexValue.HexString(val));
}
encryptStr = String();
} catch (Exception e) {
throw new RuntimeException(e);
}
return encryptStr;
}
public static String encrypt16(String encryptStr) {
return encrypt32(encryptStr).substring(8, 24);
}
public static void main(String[] args) {
String encryptStr = "22222222222,./.,./.,./!@#$%^&*()";
java加密方式有哪些System.out.pt32(encryptStr));
System.out.pt16(encryptStr));
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。