PemDocument

class PemDocument(val label: PemLabel, val content: ByteString)(source)

Represents a single PEM (Privacy-Enhanced Mail) document as defined by RFC 7468, consisting of a textual label, and the binary content it encapsulates

To encode the document into a PEM-encoded string use one of encodeToString, encodeToByteArray, encodeToByteString, or encodeToSink depending on the desired output type

Encoding produces the canonical PEM form:

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

Creation of document instances can be done using one of the following methods:

PemDocument is an immutable, thread-safe value object, with structural equality and hash code that uses both label and content.

Constructors

Link copied to clipboard
constructor(label: PemLabel, content: ByteString)

Creates a new PemDocument with the provided label and content

constructor(label: PemLabel, content: ByteArray)

Creates a new PemDocument with the provided label and content

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Raw binary payload (commonly DER or any arbitrary bytes) that is base64-armored when encoded to PEM

Link copied to clipboard

Case-sensitive encapsulation label (for example, "CERTIFICATE" or "PRIVATE KEY")

Functions

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard
fun encodeToSink(sink: Sink)

Encodes this document to the provided sink as a string in PEM format

Link copied to clipboard

Encodes this document into a String in PEM format

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Returns true if other is a PemDocument with the same label and content

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code consistent with equals, computed from label and content

Link copied to clipboard
open override fun toString(): String

Returns a concise debug representation of this document including its label and content