Recently in the business scenario, we need to Base64 decrypt the characters passed in by the third party, parse the data according to the parsing tools provided by the third-party document, and parse the Base64 as follows:
String sign = "xxxxxxxxxxxxxxxxxxxxxxxx"; Sun.misc.BASE64Decoder decode = new Sun.misc.BASE64Decoder (); String json = new string (Decode.decodebuffer (sign));
Using Sun.misc.BASE64Decoder to parse the data, the test environment tests found that the parsed string was correct,
But after the launch, according to the third party's sign, after parsing out the string finally found a character "7", the query logic did not find the problem, The final guess is sun.misc.BASE64Decoder out of the problem, so change the Base64 resolution Jira, using the following code to parse:
String sign = "xxxxxxxxxxxxxxxxxxxxxxxxx"; Base64 base64 = new Base64 (); String json = new String (Base64.decodebase64 (Sign.getbytes ()));
Found the data returned in JSON is OK, problem solved.
Java Base64 Parsing