您的位置:首页 > 运维架构 > Apache

[随手记]Android import org.apache.commons.codec.binary.Base64

2016-03-31 11:21 531 查看
转帖请注明原出处: http://blog.csdn.net/yezisuifengbiao/article/details/51024611

跟后台上传图片时,转BASE64后再用AES加密时。后台使用的是  import org.apache.commons.codec.binary.Base64 包的encodeBase64String.

Android 的 Base64 的package 是import android.util.Base64; 

只能使用  encodeToString 方法。但是加密出来的数据,跟后台使用 apache 的包并不一样。

原因是因为传入的 Base64.DEFAULT 。 通过搜索得知:

Android's Base64 includes line terminators. To obtain the same result as with the Apache encoding, use Base64.NO_WRAP

下面是原帖:

http://stackoverflow.com/questions/17912119/is-there-any-difference-between-apaches-base64-encodebase64-and-androids-base6
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息