在那些解码网站上:http://www1.tc711.com/tool/BASE64.htm是解码出来的,但是在安卓解不出来,不知道为什么??
求熟悉的帮破一下,这个东西搞了一个多少时....搞不懂,都同样的代码,怎么就不行呢?
提示错误:是不是在java有什么特殊情况解码呢?这乱码在网站都是可以解出来
java.lang.IllegalArgumentException: bad base-64
package china.testfour;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
String context = "WzAwOjAxLjQ2XeS9nOivjTrpu4TlrrbpqbkNClswMDowMi41MV3kvZzmm7I66buE5a626am5DQpbMDA6MzYuODVd5LuN5piv6Zuo5aScDQpbMDA6MzguODZd5Yed5pyb56qX5aSW5rKJ6buY55qE5aSp6ZmFDQpbMDA6NDMuMjZd6Zeu6IuN5aSp5Y+v5Lya55+l5b+D6YeM55qE5oSf6KeJDQpbMDA6NTIuOTZd6ZqP552A5bKB5pyIDQpbMDA6NTQuNjdd5peg5bC954ix5b+16JeP5Zyo5LqO5b+D6YeMDQpbMDA6NTkuMDNd6LGh5Yaw5bCB55qE55y85YWJ5aSx5Y675LqG5pa55ZCRDQpbMDE6MDguNDRd6K6p6Zuo54K56L276L2755qE5rSS6L+HDQpbMDE6MTEuOTdd5by65oqK5b+n6YOB5YaN5o6p55uWDQpbMDE6MTUuMzFd5YOP56KO5pif6Zeq6Zeq5LqO5aSp56m65Y+r5ZSk5L2gDQpbMDE6MjYuNzBd6YGl5pyb55u85pybDQpbMDE6MjguMjBd6IO95YOP5riF6aOO6Zmq5Ly05aW56aOY5Y67DQpbMDE6MzIuNjNd6K6p5a2k5Y2V55qE6IeC5byv5LiA5YaN5oqx57Sn5L2gDQpbMDE6NDIuNDNd5Zue5pyb5b6A5pel5aaC6Zu+5Ly85qKmDQpbMDE6NDUuODhd5peg5aWI55qE6L275Y+55piv5aW555qE5qyi56yR5aOwDQpbMDE6NTIuNzhd6aOO5Ly86L275ZC56L+HDQpbMDE6NTcuOTFd6K6p6Zuo54K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Fd5LuN5piv6Zuo5aScDQpbMDQ6MjkuOTZd5Yed5pyb56qX5aSW5rKJ6buY55qE5aSp6ZmFDQpbMDQ6MzQuMzNd6Zeu6IuN5aSp5Y+v5Lya55+l5b+D6YeM55qE5oSf6KeJDQpbMDQ6NDcuODJd6ZqP552A5bKB5pyIDQpbMDQ6NDkuMzdd5peg5bC954ix5b+16JeP5Zyo5LqO5b+D6YeMDQpbMDQ6NTMuNjNd6LGh5Yaw5bCB55qE55y85YWJ5aSx5Y675LqG5pa55ZCRDQo=";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String result = new String(Base64.decode(context,Base64.DEFAULT));
Log.d("ddd", result);
}
}
Android端:
编码:String oneBaseEncoder = Base64.encode(msg.getBytes());
解码:String oneBaseDecoder = new String(Base64.decode(msg));
JAVA WEB端:
编码:String oneBaseEncoder = new BASE64Encoder().encode(jsonString.getBytes("utf-8"));
解码:String oneBaseDecoder = new String(new BASE64Decoder().decodeBuffer(jsonString));
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。