mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 02:39:39 +02:00
Add EncryptionBuilder.discardOutput()
Also move NullOutputStream from pgpainless-sop to pgpainless-core
This commit is contained in:
parent
80cf1a7446
commit
b96f22d0a9
4 changed files with 18 additions and 8 deletions
|
@ -53,15 +53,10 @@ class DetachedSignImpl : DetachedSign {
|
|||
}
|
||||
}
|
||||
|
||||
// When creating a detached signature, the output of the signing stream is actually
|
||||
// the unmodified plaintext data, so we can discard it.
|
||||
// The detached signature will later be retrieved from the metadata object instead.
|
||||
val sink = NullOutputStream()
|
||||
|
||||
try {
|
||||
val signingStream =
|
||||
PGPainless.encryptAndOrSign()
|
||||
.onOutputStream(sink)
|
||||
.discardOutput()
|
||||
.withOptions(ProducerOptions.sign(signingOptions).setAsciiArmor(armor))
|
||||
|
||||
return object : ReadyWithResult<SigningResult>() {
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.sop
|
||||
|
||||
import java.io.OutputStream
|
||||
|
||||
/** [OutputStream] that simply discards bytes written to it. */
|
||||
class NullOutputStream : OutputStream() {
|
||||
|
||||
override fun write(p0: Int) {
|
||||
// nop
|
||||
}
|
||||
|
||||
override fun write(b: ByteArray) {
|
||||
// nop
|
||||
}
|
||||
|
||||
override fun write(b: ByteArray, off: Int, len: Int) {
|
||||
// nop
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
// nop
|
||||
}
|
||||
|
||||
override fun flush() {
|
||||
// nop
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue