Skip to content

Module cryptography-serialization-pem

PEM: encoding/decoding of PEM content from/to String or ByteArray

The module is currently experimental and is subject to API/ABI changes

Example

val encodedPemContent: String = PEM.encode(
    PemContent(
        label = PemLabel("KEY"),
        bytes = "Hello World".encodeToByteArray()
    )
)

println(encodedPemContent)

val decodedPemContent: PemContent = PEM.decode(
    """
    -----BEGIN UNKNOWN-----
    SGVsbG8gV29ybGQ=
    -----END UNKNOWN-----

    """.trimIndent(),
)

println(decodedPemContent.bytes.decodeToString()) // prints "Hello World"

Using in your projects

dependencies {
    implementation("dev.whyoleg.cryptography:cryptography-serialization-pem:0.4.0")
}

Package dev.whyoleg.cryptography.serialization.pem

PEM: encoding/decoding of PEM files from/to String or ByteArray