Android Kotlin Base64 Encode/Decode

Kevin FOO
Mar 22, 2021

--

Simple app to encode/decode string to/from base64

Top multi line edit text for text, bottom multi line edit text for base 64. Clicking [Encode] will take input from top edit text and output at bottom edit text. Clicking [Decode] will take input from bottom edit text and output at the top edit text.

btnEncode?.setOnClickListener {
val
input = etText?.text.toString()
val byte = input.toByteArray(charset("UTF-8"))
val base64 = Base64.getEncoder().encodeToString(byte)
etBase64?.setText(base64)
}

btnDecode?.setOnClickListener {
val
input = etBase64?.text.toString()
val byte = Base64.getDecoder().decode(input)
val text = String(byte, charset("UTF-8"))
etText?.setText(text)
}

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet