这是apache-james里用户密码加密的方法,第一个参数是密码,第二个参数是算法规则,谁能写出解密的方法public static String digestString(String pass, String algorithm )
            throws NoSuchAlgorithmException  {        MessageDigest md;
        ByteArrayOutputStream bos;        try {
            md = MessageDigest.getInstance(algorithm);
            byte[] digest = md.digest(pass.getBytes("iso-8859-1"));
            bos = new ByteArrayOutputStream();
            OutputStream encodedStream = MimeUtility.encode(bos, "base64");
            encodedStream.write(digest);
            return bos.toString("iso-8859-1");
        } catch (IOException ioe) {
            throw new RuntimeException("Fatal error: " + ioe);
        } catch (MessagingException me) {
            throw new RuntimeException("Fatal error: " + me);
        }
    }

解决方案 »

  1.   

    // 将 s 进行 BASE64 编码 
    public static String getBASE64(String s) { 
    if (s == null) return null; 
    return (new sun.misc.BASE64Encoder()).encode( s.getBytes() ); 
    } // 将 BASE64 编码的字符串 s 进行解码 
    public static String getFromBASE64(String s) { 
    if (s == null) return null; 
    BASE64Decoder decoder = new BASE64Decoder(); 
    try { 
    byte[] b = decoder.decodeBuffer(s); 
    return new String(b); 
    } catch (Exception e) { 
    return null; 

    }