korlibs-archive/krypto

ArrayIndexOutOfBoundsException when decoding base64

Nutriz opened this issue · 1 comments

Hi,

With Kotlin 1.4.10 and Krypto 2.0.0 I have an ArrayIndexOutOfBoundsException when I try to decode
the payload example JWT at https://jwt.io/.

val payload = Base64.decode("eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ")
2020-11-27 10:09:05.331 13401-13401/com.ale.rainbowsdk2.androidApp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ale.rainbowsdk2.androidApp, PID: 13401
    java.lang.ArrayIndexOutOfBoundsException: length=74; index=74
        at com.soywiz.krypto.encoding.Base64.readU8(Base64.kt:83)
        at com.soywiz.krypto.encoding.Base64.decode(Base64.kt:38)
        at com.soywiz.krypto.encoding.Base64.decode(Base64.kt:18)
        at com.soywiz.krypto.encoding.Base64.decodeIgnoringSpaces(Base64.kt:22)
        at com.ale.rainbowsdk2.shared.RainbowApi.getExpiredTime(RainbowApi.kt:128)
        ...

Fixed in 2.0.1