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)
}