Input byte array has incorrect ending byte at 40
Okay, I found out. The original String is encoded on an Android device using android.util.Base64
by Base64.encodeToString(json.getBytes("UTF-8"), Base64.DEFAULT);
. It uses android.util.Base64.DEFAULT
encoding scheme.
Then on the server side when using java.util.Base64
this has to be decoded with Base64.getMimeDecoder().decode(payload)
not with Base64.getDecoder().decode(payload)
I was trying to use the strings from the args. I found that if I use arg[0].trim()
that it made it work. eg
Base64.getDecoder().decode(arg[0].trim());
I guess there's some sort of whitespace that gets it messed up.