Reference:
Http://www.360doc.com/content/10/1103/12/1485725_66213001.shtml (urlencode)
http://blog.csdn.net/uikoo9/article/details/27981219
The data in the computer is binary, whether it is a string or a file, and the encryption is binary,
What we want to see is often a string, this article describes the conversion of byte[] into a variety of binary and Base64 Encoding.
is a coding method, can be understood as a complex binary, many algorithms are encrypted after the output is byte[], and this byte[] the form we show is not friendly (garbled),
So it is generally converted to base64, and of course can be converted into other systems.
public static void main (string[] S) {
String sss = "AA123AA program";
byte[] bytes = null;
try {
bytes = Sss.getbytes ("UTF-8");
For (byte b:bytes) {
System.out.print (b + "(#)");
}
} catch (unsupportedencodingexception E) {
E.printstacktrace ();
}
String encode;
try {
encode = Base64.encode (bytes);
System.out.println ("\nbase64.encode result:" + encode);
byte[] bytess = Base64.decode (encode);
For (byte B:bytess) {
System.out.print (b + "(#)");
}
String sss2 = new string (bytess, "UTF-8");
System.out.print ("\nsss2 = = =" + sss2);
SSS = "Aa123 AA Program # program * Program +and program";
encode = Java.net.URLEncoder.encode (sss, "UTF-8");
System.out.println ("\njava.net.urlencoder result:" + encode);
String SSS3 = Urldecoder.decode (encode, "UTF-8");
System.out.println ("\njava.net.urldecoder result:" + sss3);
} catch (Exception E) {
E.printstacktrace ();
}
Operation Result:
65 (#) 97 (#) 49 (#) 50 (#) 51 (#) 65 (#) 97 (#)-25 (#)-88 (#)-117 (#)-27 (#)-70 (#)-113 (#)
Base64.encode results: qwexmjnbyeeoi+w6jw==
65 (#) 97 (#) 49 (#) 50 (#) 51 (#) 65 (#) 97 (#)-25 (#)-88 (#)-117 (#)-27 (#)-70 (#)-113 (#)
Sss2 = = = AA123AA Program
Java.net.URLEncoder results: aa123+aa%e7%a8%8b%e5%ba%8f%23%e7%a8%8b%e5%ba%8f*%e7%a8%8b%e5%ba%8f%2band%e7%a8%8b%e5%ba% 8F
Java.net.URLDecoder results: Aa123 AA Program # program * Program +and Program
Java Urlencoder and Base64.encode ()