In a project, encountered an interesting problem, after invoking a third-party interface callback local code, the encrypted request parameter decryption and transcoding, one of the decoding method is invalid, another decoding method valid, what solution? :
1. Encrypt a string when invoking a third-party interface:
String str = "AKDFJLKSJFDLJSDLFSLFLD";
(New Base64encoder ()). Encodebuffer (Str.getbytes ());
2, synchronous callback local code when decrypting and transcoding the string, using the following transcoding scheme is not a problem, while the asynchronous callback local code when decrypting and transcoding the string, using the following transcoding scheme has the problem:
String Merpriv = Request ("Merpriv");
String newmerpriv = new String ((New Base64decoder ()). Decodebuffer (Merpriv));
Newmerpriv = Urldecoder.decode (Newmerpriv, "UTF-8"). Trim ();
3, the asynchronous callback local code when decrypting and transcoding the string, using the following transcoding scheme no problem:
String Merpriv = Request ("Merpriv");
String newmerpriv = new String ((New Base64decoder ()). Decodebuffer (Merpriv));
Newmerpriv = new String (newmerpriv.getbytes ("iso-8859-1"), "UTF-8");
Java garbled and transcoding problems