diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/DetachedSignImpl.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/DetachedSignImpl.java index c32cb219..4f74b9ee 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/DetachedSignImpl.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/DetachedSignImpl.java @@ -4,7 +4,6 @@ package org.pgpainless.sop; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -92,10 +91,10 @@ public class DetachedSignImpl implements DetachedSign { } } - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + OutputStream sink = new NullOutputStream(); try { EncryptionStream signingStream = PGPainless.encryptAndOrSign() - .onOutputStream(buffer) + .onOutputStream(sink) .withOptions(ProducerOptions.sign(signingOptions) .setAsciiArmor(armor)); diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/NullOutputStream.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/NullOutputStream.java new file mode 100644 index 00000000..9977ba28 --- /dev/null +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/NullOutputStream.java @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2024 Paul Schaub +// +// SPDX-License-Identifier: Apache-2.0 + +package org.pgpainless.sop; + +import java.io.OutputStream; + +/** + * {@link OutputStream} that simply discards bytes written to it. + */ +public class NullOutputStream extends OutputStream { + @Override + public void write(int b) { + // NOP + } +}