Java Base64 parsing

In recent business scenarios, it is necessary to perform base64 decryption on the characters passed in by a third party. According to the parsing tool provided by the third-party document, the data is parsed. The Base64 parsing method is as follows:

              String sign = "xxxxxxxxxxxxxxxxxxxxxxxx";
              sun.misc.BASE64Decoder decode = new sun.misc.BASE64Decoder();
	      String json = new String(decode.decodeBuffer(sign));

  Use sun.misc.BASE64Decoder to parse the data, put it in the test environment to test and find that the parsed string is correct.

But after going online, according to the sign passed by the third party, after parsing it, it was found that there was an extra character "7" at the end of the string, and the query logic did not find any problems. The last guess was that there was a problem with sun.misc.BASE64Decoder, so Base64 was replaced. To parse jira, use the following code to parse:

 

String sign = "xxxxxxxxxxxxxxxxxxxxxxxxx";
Base64 base64 = new Base64();
String json = new String (base64.decodeBase64(sign.getBytes()));

  It is found that the data in the returned json is normal, and the problem is solved.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325036307&siteId=291194637