首先我用的是:org.apache.commons.codec.binary.Base64
编码、解码代码如下:
String source = "Tom";
String encode = new String(Base64.encodeBase64(source.getBytes()));
System.out.println(encode);
encode = "VG9tV";
System.out.println(new String(Base64.decodeBase64(encode)));
输出结果为:
VG9t
Tom
疑问:为什么我把编码之后的字符串改了,再用改的这个字符串来解码,却还是得到的是原来的字符串?