import java.security.MessageDigest;
import static io.netty.util.internal.StringUtil.byteToHexString;
public class TestMd5 {
private final static String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d",
"e", "f"};
private static String MD5Encode(String origin) {
String resultString = null;
try {
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
StringBuffer resultSb = new StringBuffer();
byte[] b = md.digest(resultString.getBytes());
for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i]));
}
return resultSb.toString();
} catch (Exception ex) {
ex.printStackTrace();
}
return resultString;
}
public static void main(String[] args ){
System.out.println(MD5Encode("奥斯"));
}
}
MD5 加密
最新推荐文章于 2024-06-28 10:11:02 发布