encodeToByteString

Encodes this document into a ByteString as a string in PEM format

The output uses the form:

-----BEGIN {label}-----
Base64-encoded {content} with line breaks every 64 characters
-----END {label}-----

Return

the bytes representing PEM-encoded string

Samples

val document = PemDocument(
    label = PemLabel("CUSTOM"),
    content = "hello world".encodeToByteString(),
)

val encoded = document.encodeToByteString()

assertEquals(
    expected = """
    -----BEGIN CUSTOM-----
    aGVsbG8gd29ybGQ=
    -----END CUSTOM-----
    
    """.trimIndent().encodeToByteString(),
    actual = encoded
)