想用加密算法,MD5。。
    系统类包中有这样一个类sun.security.provider.MD5 
    谁有关于这个包的介绍。找了半天也没找到。。
    这个包就是md5加密的包把。
 还有,谁能给我个简单点的例子。。
    String a="1";
   通过MD5 加密 a;
   输出 a;
   谢谢各位高手了

解决方案 »

  1.   

    public  String ToString(String src)
    {
        byte[] result = null;
        String tt="";
        try 
        {
             MessageDigest alg = java.security.MessageDigest.getInstance("MD5");
             alg.update(src.getBytes());
             result = alg.digest();
             for(int i=0;i<result.length;i++)
             {
              tt +=(char)result[i];
             }
             
             return tt;    }
        catch (Exception ex) {return null;
        }
        
    }
    public  String byte2hex(String b){
    String hs="";
    String stmp="";
    byte[] bb=b.getBytes();
    for(int n=0;n<bb.length;n++){
    stmp=(java.lang.Integer.toHexString(bb[n] & 0XFF));
    if(stmp.length()==1) hs=hs+"0"+stmp;
    else hs=hs+stmp;
    //if(n<b.length-1) hs=hs+":";
    }
    return hs.toUpperCase();
    }