29

Sample A (using org.apache.commons.codec.binary.Base64):

Base64.encodeBase64("foobar".getBytes()); 

Sample B (using android.util.Base64):

Base64.encode("foobar".getBytes(), Base64.DEFAULT); 

Do these produce the same string?

Alex Florescu
  • 5,096
  • 1
  • 28
  • 49

1 Answers1

82

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.

Alex Florescu
  • 5,096
  • 1
  • 28
  • 49