java md5工具类

java 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;
}

编程技巧