I'm getting a "java.lang.IllegalArgumentException: bad base-64" on the following code:
byte[] msgBytes = Base64.decode(msgStr, Base64.NO_WRAP);
msgString is a String, and right before this line, I check the value of msgStr and it is "fl-ILw==". Is there anything wrong?
Thanks.
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.
By consisting only of ASCII characters, base64 strings are generally url-safe, and that's why they can be used to encode data in Data URLs.
Base64 Decode is very unique tool to decode base64 data to plain text. This tool saves your time and helps to decode base64 data. This tool allows loading the Base64 data URL, which loads base64 encoded text and decodes to human readable text.
Base64 images are primarily used to embed image data within other formats like HTML, CSS, or JSON. By including image data within an HTML document, the browser doesn't need to make an additional web request to fetch the file, since the image is already embedded in the HTML document.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With