MD5工具类应用
1. MD5的加密工具类
2. 来自:as3-core-lib: http://code.google.com/p/as3corelib/
3. 用法:var encryptedStr:String =MD5.hash(rawstring);
?
public static String md5(String str) { String s = str; if (s == null) { return ""; } else { System.out.println(s); String value = null; MessageDigest md5 = null; try { md5 = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } @SuppressWarnings("restriction") sun.misc.BASE64Encoder baseEncoder = new sun.misc.BASE64Encoder(); try { @SuppressWarnings("restriction") String encode = baseEncoder.encode(md5.digest(s.getBytes("utf-8"))); value = encode; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return value; } }
?
5.? http://blog.sina.com.cn/s/blog_674522cd01010wnd.html