I have a base64 encoded string. It looks like this:
eyJibGExIjoiYmxhMSIsImJsYTIiOiJibGEyIn0=
Any online tool can decode this to the desired line, which is {"bla1":"bla1","bla2":"bla2"} . However, my Java implementation fails:
import java.util.Base64; System.out.println("payload = " + payload); String json = new String(Base64.getDecoder().decode(payload));
I get the following error:
payload = eyJibGExIjoiYmxhMSIsImJsYTIiOiJibGEyIn0= java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 40
What is wrong with my code?
source share