有Apache的Base64.en codeBase64和Android的Base64.en code与Base64.Default标志有什么区别?有什么区别、标志、en、Apache

2023-09-06 01:40:02 作者:敷衍

样品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.