https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
c

chris-horner

11/12/2020, 3:18 AM
Works like a charm with a
ForwardingSink
Copy code
private class UnclosingSink(output: OutputStream) : ForwardingSink(output.sink()) {
  override fun close() {
    delegate.flush()
  }
}
Copy code
fun getEncryptedSink(output: OutputStream): Sink {
  val cipher = getEncryptionCipher()
  return UnclosingSink(output).buffer()
      .writeInt(cipher.iv.size)
      .write(cipher.iv)
      .cipherSink(cipher)
}
👍 1