Java 加密Deflate并编码为Base64 Xml

Java 加密Deflate并编码为Base64 Xml,java,encoding,automation,base64,inflate,Java,Encoding,Automation,Base64,Inflate,//XML需要使用BASE64进行加密、解密和编码?我已经使用了这段代码,但没有得到确切的输出 public String encryptDeflateAndBase64(String decryptedString) throws IOException { byte[] b=decryptedString.getBytes("UTF-8"); byte[] c = new byte[550]; Deflater compresser=new D

//XML需要使用BASE64进行加密、解密和编码?我已经使用了这段代码,但没有得到确切的输出

public String encryptDeflateAndBase64(String decryptedString) throws IOException {
        byte[] b=decryptedString.getBytes("UTF-8");
        byte[] c = new byte[550];
        Deflater compresser=new Deflater();
        compresser.setInput(b);
        compresser.finish();
        System.out.println(compresser.deflate(c));
        compresser.end();
        /*ByteArrayOutputStream bos = new ByteArrayOutputStream(decryptedString.length());
        byte[] buf = new byte[4096];
        while (!compresser.finished()) {
            int count = compresser.deflate(buf);
            bos.write(buf, 0, count);
        }
        bos.close();
        byte[] compressedData = bos.toByteArray();
*/       byte[] output = Base64.encodeBase64(c);
        return new String(output);
    }
在这里,我使用了java.util.Base64。为了不复制字节,我使用了ByteBuffer。

您希望得到什么(“精确”)输出?你为什么期望它(与实际情况不同)。。我在代码片段中没有看到“加密”,只有(base64)“编码”。
    //Remove: System.out.println(compresser.deflate(c));
    int count = compresser.deflate(c);
    ByteBuffer bb = ByteBuffer.wrap(c, 0, count);
    byte[] output = Base64.getEncoder().encode(bb);