Skip to content Skip to sidebar Skip to footer

Base64 Decoder In Android In Api Level 7

How to decode a base64 encoded string to byte array on Android API level 7? Can it be done using any standard packages of Java? Should i copy the source code from google search

Solution 1:

Not sure if there's n or not, but if there isn't, I wouldn't implement your own, I'd use something like Mikael Grev's MiGBase64 which has been extensively tested and (as far as I can see) should work on Android

Much later edit

It was added in v8 (android 2.2). See android.util.Base64

Solution 2:

I had to use Base64.NO_WRAP on Android to make it match plain Java results

  • Plain Java==>DatatypeConverter.printBase64Binary( string2Encode.getBytes() );
  • Android==> Base64.encodeToString( string2Encode.getBytes(), Base64.NO_WRAP );

Solution 3:

You can use this class,

org.bouncycastle.util.encoders.Base64

BouncyCastle is included in Level 7.

Post a Comment for "Base64 Decoder In Android In Api Level 7"