2. import org.apache.commons.codec.binary.Base64;
3. 使用Base64 Class进行编码与解码
Base64 base64 = new Base64();
//使用Base64进行字串编码
String encodeString = new String(base64.encode("This is source string.".getBytes()));
//输出结果将为"VGhpcyBpcyBzb3VyY2Ugc3RyaW5nLg=="
System.out.println(encodeString);
//使用Base64进行字串解码
String decodeString = new String(base64.decode(encodeString.getBytes()));
//输出结果将为"This is source string."
System.out.println(decodeString);




沒有留言:
張貼留言