md = MessageDigest.getInstance("MD5"); byte[] b = md.digest(str.getBytes()); StringBuffer buf = new StringBuffer(); for ( int i=0; i<b.length; i++ )    { int j = (b[i]<0) ? 256+b[i] : b[i]; if ( j<10 ) buf.append("0"); buf.append(Integer.toHexString(j)); } return buf.toString();
return encode (str.getBytes());
    public static String encode(String str) throws NoSuchAlgorithmException {        md = MessageDigest.getInstance("MD5");        byte[] b = md.digest(str.getBytes());        StringBuffer buf = new StringBuffer();        for ( int i=0; i<b.length; i++ )    {            int j = (b[i]<0) ? 256+b[i] : b[i];            if ( j<10 ) buf.append("0");            buf.append(Integer.toHexString(j));        }        return buf.toString();    }