Bad base-64 error

后端 未结 1 1618
星月不相逢
星月不相逢 2020-12-11 04:05

I\'m getting a \"java.lang.IllegalArgumentException: bad base-64\" on the following code:

byte[] msgBytes = Base64.decode(msgStr, Base64.NO_WRAP);

相关标签:
1条回答
  • 2020-12-11 04:38

    According to RFC 4648(http://www.rfc-editor.org/rfc/rfc4648.txt) '-' character is not a valid Base64 character but on the other hand is valid for "URL and Filename safe Base 64 Alphabet".

    So you could use Base64.URL_SAFE depending of the expected format of the string.

    0 讨论(0)
提交回复
热议问题