encodeToSink
Encodes this document to the provided sink as a string in PEM format
The output uses the form:
-----BEGIN {label}-----
Base64-encoded {content} with line breaks every 64 characters
-----END {label}-----Content copied to clipboard
Parameters
sink
the destination to write bytes representing PEM-encoded string into
Samples
val document = PemDocument(
label = PemLabel("CUSTOM"),
content = "hello world".encodeToByteString(),
)
val buffer = Buffer()
document.encodeToSink(buffer)
val encoded = buffer.readString()
assertEquals(
expected = """
-----BEGIN CUSTOM-----
aGVsbG8gd29ybGQ=
-----END CUSTOM-----
""".trimIndent(),
actual = encoded
)Content copied to clipboard