package cn.sh.steven.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class CipherUtil {
public CipherUtil() {
}
public static void main(String[] args) {
String test = "WuXingJie3LouHB!!*1";
new CipherUtil();
String result = MD5Encrypt(test);
System.out.println(result);
}
public static String MD5Encrypt(String inStr) {
MessageDigest md = null;
String outStr = null;
try {
md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(inStr.getBytes());
outStr = bytetoString(digest);
} catch (NoSuchAlgorithmException var4) {
var4.printStackTrace();
}
return outStr;
}
public static String bytetoString(byte[] digest) {
String str = "";
String tempStr = "";
for(int i = 0; i < digest.length; ++i) {
tempStr = Integer.toHexString(digest[i] & 255);
if(tempStr.length() == 1) {
str = str + "0" + tempStr;
} else {
str = str + tempStr;
}
}
return str.toLowerCase();
}
}
04-07