<<< Java生成Md5
package cn.sevennight.test; import java.security.MessageDigest; public class md5{ public static String MD5(String text) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(text.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 += 256; if (i < 16) buf.append("0"); buf.append(Integer.toHexString(i)); } return new String(buf.toString()); } catch (Exception e) { e.printStackTrace(); return ""; } } public static void main(String[] args) { String md5 =MD5("123456"); System.out.println(md5); } }