样品A(使用org.apache.commons codec.binary.Base64。):
Sample A (using org.apache.commons.codec.binary.Base64):
Base64.encodeBase64("foobar".getBytes());
样品B(使用android.util.Base64):
Sample B (using android.util.Base64):
Base64.encode("foobar".getBytes(), Base64.DEFAULT);
做这些产生相同的字符串?
Do these produce the same string?
没有,所不同的是默认设置,Android的Base64的,包括行终止符。以获得相同的结果与Apache编码,使用Base64.NO_WRAP
No, the difference is that with the default settings, Android's Base64 includes line terminators. To obtain the same result as with the Apache encoding, use Base64.NO_WRAP.