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)
Content copied to clipboard
See also
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 newDecoderFeedProtected(out: Decoder.OutFeed): Decoder.Feed<Base64.Config>
Link copied to clipboard
protected open override fun newEncoderFeedProtected(out: Encoder.OutFeed): Encoder.Feed<Base64.Config>