Ktor - How to decode base64 token using pure Kotlin in a Kotlin-Multiplatform common module?

Viewed 984

It might seem simple at first, but considering that we cannot use the java.util package in the common module of a Kotlin Multiplatform project, I am wondering how to decode a base64 string using pure Kotlin code.

Already tried:

  • using expect/actual methods: works fine for Android, but did not work for iOS! It seems like the Swift methods and classes that are for Base64 decoding cannot be used in the kmm module!
  • using Ktor's Base64 decoding methods: The Ktor Base64 decoder seems to be an internal Ktor API which I could not use in my KMM project. I also mentioned that it is marked as deprecated for version 1.4.1 in the ktor docs.

I was wondering if there are any other workarounds to decode a Base64 string in a kmm common module.

1 Answers
Related