Input byte array has incorrect ending byte at 40

后端 未结 3 1357
攒了一身酷
攒了一身酷 2021-02-19 00:32

I have a string that is base64 encoded. It looks like this:

eyJibGExIjoiYmxhMSIsImJsYTIiOiJibGEyIn0=

Any online tool can decode this to the pro

3条回答
  •  甜味超标
    2021-02-19 00:39

    Maybe too late, but I also had this problem.

    By default, the Android Base64 util adds a newline character to the end of the encoded string.
    The Base64.NO_WRAP flag tells the util to create the encoded string without the newline character.

    Your android app should encode src something like this:

    String encode = Base64.encodeToString(src.getBytes(), Base64.NO_WRAP);
    

提交回复
热议问题