- Thread Author
- #1
`val obj = JSONObject(jwt) val data = obj.getString("data")
I tried using this method but didn't work
`fun decodeBase64String(encodedString: String): String { val encodedStream: InputStream = ByteArrayInputStream(encodedString.toByteArray(Charsets.UTF_8)) val base64Stream = Base64InputStream(encodedStream)
}'
Code:
`val obj = JSONObject(jwt) val data = obj.getString("data")
val encryptedStr = data.split(".")
val encryptedStrSplit = encryptedStr[1]
// decrypt using Base64.decode
val decodeResponse = android.util.Base64.decode(encryptedStrSplit, android.util.Base64.URL_SAFE).toString(Charsets.UTF_8)
Timber.tag("OK").d("decodeResponse: $decodeResponse")
return decodeResponse`
I tried using this method but didn't work
`fun decodeBase64String(encodedString: String): String { val encodedStream: InputStream = ByteArrayInputStream(encodedString.toByteArray(Charsets.UTF_8)) val base64Stream = Base64InputStream(encodedStream)
Code:
val decodedBytes = base64Stream.readBytes()
return decodedBytes.toString(Charsets.UTF_8)