这里最好建议,每一个字符分开编码后再加上特殊字符,然后再组合输出。否则直接 解码后,仍然能看到20字样
public static void main(String[] args) {
//编码//可以在编码后的字符串 再加 一串特殊字符 如~+%q
String a = "20";
BASE64Encoder base64en = new BASE64Encoder();
String requestValue=base64en.encode(a.getBytes());
requestValue = requestValue + "21q~+%q";
System.out.println(requestValue);
//解码 ,去掉特殊字符后再解密
String jmStr = requestValue.replace(<span style="font-family: Arial, Helvetica, sans-serif;">"21q~+%q"</span><span style="font-family: Arial, Helvetica, sans-serif;">, "");</span><span style="font-family: Arial, Helvetica, sans-serif;"> ;</span>
BASE64Decoder decode = new BASE64Decoder();
try {
byte[] value = decode.decodeBuffer(jmStr);
String srt2=new String(value, "utf-8");
System.out.println(srt2);
} catch (IOException e) {
e.printStackTrace();
}
}