android7使用base64,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 results?

Should i re-implement encoder and decoder according to RFC?

PS: API level 8 has util package android.util.Base64 that does this, but i have to do development based on API level 7.

回答1:

You can use this class,

org.bouncycastle.util.encoders.Base64

BouncyCastle is included in Level 7.

回答2:

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

回答3:

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 );

来源:https://stackoverflow.com/questions/3116937/base64-decoder-in-android-in-api-level-7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值