Default

Common
JVM
JS
Native
1.0
companion object Default : Base64
(source)

The "base64" encoding specified by RFC 4648 section 4, Base 64 Encoding.

Uses "The Base 64 Alphabet" as specified in Table 1 of RFC 4648 for encoding and decoding, consisting of 'A'..'Z', 'a'..'z', '+' and '/' characters.

This instance is configured with the padding option set to PaddingOption.PRESENT. Use the withPadding function to create a new instance with a different padding option if necessary.

Encode operation does not add any line separator character. Decode operation throws if it encounters a character outside the base64 alphabet.

import kotlin.io.encoding.*
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val encoded = Base64.Default.encode("Hello? :> ".encodeToByteArray())
println(encoded) // SGVsbG8/IDo+IA==
//sampleEnd
}

Companion Object Properties

Common
JVM
JS
Native
1.0

Mime

The encoding specified by RFC 2045 section 6.8, Base64 Content-Transfer-Encoding.

val Mime: Base64
Common
JVM
JS
Native
1.0

UrlSafe

The "base64url" encoding specified by RFC 4648 section 5, Base 64 Encoding with URL and Filename Safe Alphabet.

val UrlSafe: Base64