Base64

Base64 encoding/decoding in accordance with RFC 4648 section 4 & 5 (Default & UrlSafe)

https://www.ietf.org/rfc/rfc4648.html#section-4 https://www.ietf.org/rfc/rfc4648.html#section-5

Decodes both Default and UrlSafe, while encoding to UrlSafe can be configured via the Base64.Config.

e.g.

val base64 = Base64 {
    isLenient = true
    lineBreakInterval = 64
    encodeToUrlSafe = false
    padEncoded = true
}

val text = "Hello World!"
val bytes = text.encodeToByteArray()
val encoded = bytes.encodeToString(base64)
println(encoded) // SGVsbG8gV29ybGQh

// Alternatively, use the static implementaton instead of
// configuring your own settings.
val decoded = encoded.decodeToByteArray(Base64.Default).decodeToString()
assertEquals(text, decoded)

See also

Constructors

Link copied to clipboard
constructor(config: Base64.Config)

Types

Link copied to clipboard

Configuration for Base64 encoding/decoding.

Link copied to clipboard

Doubles as a static implementation with default settings and a lineBreakInterval of 64.

Link copied to clipboard

Doubles as a static implementation with default settings and a lineBreakInterval of 64.

Functions

Link copied to clipboard
protected open override fun name(): String
Link copied to clipboard
Link copied to clipboard