For Kotlin mb better to use this:
fun String.decode(): String {
return Base64.decode(this, Base64.DEFAULT).toString(charset("UTF-8"))
}
fun String.encode(): String {
return Base64.encodeToString(this.toByteArray(charset("UTF-8")), Base64.DEFAULT)
}
Example:
Log.d("LOGIN", "TEST")
Log.d("LOGIN", "TEST".encode())
Log.d("LOGIN", "TEST".encode().decode())