md5工具类

9/6/2015来源:Java教程人气:2122

md5工具类import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import sun.misc.BASE64Encoder;publicstaticStringmd5(String str){ MessageDigest md5; String jiustr = str; String xinstr = "" ;try{ md5 = MessageDigest.getInstance( "MD5");byte[] bs = md5.digest(jiustr.getBytes()); BASE64Encoder encoder =newBASE64Encoder(); xinstr = encoder.encode(bs); }catch(NoSuchAlgorithmException e) { e.PRintStackTrace(); }returnxinstr; }