Is there any difference between Apache's Base64.encodeBase64 and Android's Base64.encode with Base64.Default flag?

16,480

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.

Share:
16,480
Alex Florescu
Author by

Alex Florescu

Build things, break things, have fun. T: @flor3scu Careers page

Updated on June 05, 2022

Comments

  • Alex Florescu
    Alex Florescu almost 2 years

    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?