MD5
来源:互联网 发布:linux服务器使用教程 编辑:程序博客网 时间:2024/06/14 16:30
使用MD5示例:
public class MD5Encoder { public static String encode(String string) throws Exception{ byte[] hash= MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")); StringBuilder hex=new StringBuilder(hash.length*2); for (byte b:hash) { if((b & 0xFF) < 0x10){ hex.append("0"); } hex.append(Integer.toHexString(b & 0xFF)); } return hex.toString(); }}
0 0