跨平台base64数据传输注意问题
今天用base64编码传输json串,android端那边始终看不到图片!
首先发现android端接收的json串长度不一致,仔细研究发现android端接收到的json数据里把服务器数据里的"/"和"+"过滤掉了。
查看资料发现,之前使用:new BASE64Encoder().encode(bytes)来转byte[]。
跨平台传输base64编码数据需使用:Base64.encodeBase64URLSafeString(bytes)(方法含义:将二进制数据编码使用URL安全变化的Base64算法但不块输出)。
Modifier and Type | Method and Description |
---|---|
static byte[] |
decodeBase64(byte[] base64Data)
Decodes Base64 data into octets
|
static byte[] |
decodeBase64(String base64String)
Decodes a Base64 String into octets
|
static BigInteger |
decodeInteger(byte[] pArray)
Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature
|
static byte[] |
encodeBase64(byte[] binaryData)
Encodes binary data using the base64 algorithm but does not chunk the output.
|
static byte[] |
encodeBase64(byte[] binaryData, boolean isChunked)
Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
|
static byte[] |
encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe)
Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
|
static byte[] |
encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe, int maxResultSize)
Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
|
static byte[] |
encodeBase64Chunked(byte[] binaryData)
Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
|
static String |
encodeBase64String(byte[] binaryData)
Encodes binary data using the base64 algorithm but does not chunk the output.
|
static byte[] |
encodeBase64URLSafe(byte[] binaryData)
Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output.
|
static String |
encodeBase64URLSafeString(byte[] binaryData)
Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output.
|
static byte[] |
encodeInteger(BigInteger bigInt)
Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature
|
static boolean |
isArrayByteBase64(byte[] arrayOctet)
Deprecated.
1.5 Use
isBase64(byte[]) , will be removed in 2.0. |
static boolean |
isBase64(byte octet)
Returns whether or not the
octet is in the base 64 alphabet. |
static boolean |
isBase64(byte[] arrayOctet)
Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
|
static boolean |
isBase64(String base64)
Tests a given String to see if it contains only valid characters within the Base64 alphabet.
|
protected boolean |
isInAlphabet(byte octet)
Returns whether or not the
octet is in the Base64 alphabet. |
boolean |
isUrlSafe()
Returns our current encode mode.
|
跨平台base64数据传输注意问题的更多相关文章
- pickle\json,configparser,hashlib模块
python常用模块 目录 python常用模块 json模块\pickle模块 configparser模块 hashlib模块 subprocess模块 json模块\pickle模块 首先说一下 ...
- 跨平台传输中使用base64来保证非ascii码字符串的完整性
首先,我们来看一个例子: byte[] b=new byte[]{2,9,43}; String ss=new String(b,"utf-8"); byte[] b1=ss.ge ...
- jquery异步ajax超大长度base64图片长字段数据传输问题解决办法和php后台处理办法
2017年5月9日19:25:02 在做在线签名的时候,到了图片上传的时候,使用jquery异步ajax上传base64的图片数据的时候,使用默认的方式进行数据传输偶尔会出现 生产的图片只有上半部分, ...
- 基于 socket.io, 简单实现多平台类似你猜我画 socket 数据传输
一.前言 socket.io 实现了实时双向的基于事件的通讯机制,是基于 webSocket 的封装,但它不仅仅包括 webSocket,还对轮询(Polling)机制以及其它的实时通信方式封装成了通 ...
- Base64编码
Base64编码 写在前面 今天在做一个Android app时遇到了一个问题:Android端采用ASE对称加密的数据在JavaWeb(jre1.8.0_7)后台解密时,居然解密失败了!经过测试后发 ...
- C#跨平台手机应用开发工具Xamarin尝试 与Eclipse简单对比
Xamarin 支持使用C#开发基于Android.IOS.WindowsPhone应用开发,最大特点C#+跨平台,详细说明问度娘. 安装 研究 想体验研究的点击查看页面 Xamarin For Vi ...
- 【腾讯Bugly干货分享】微信终端跨平台组件 mars 系列(二) - 信令传输超时设计
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:http://mp.weixin.qq.com/s/9DJxipJaaBC8yC-buHgnTQ 作者简介: ...
- 如约而至:微信自用的移动端IM网络层跨平台组件库Mars已正式开源
1.前言 关于微信内部正在使用的网络层封装库Mars开源的消息,1个多月前就已满天飞(参见<微信Mars:微信内部正在使用的网络层封装库,即将开源>),不过微信团队没有失约,微信Mars ...
- Cordova+Asp.net Mvc+GIS跨平台移动应用开发实战1-系统初步搭建(附演示,apk,全部源码)
1.前言 身处在移动互联网的今天,移动应用开发炙手可热,身为程序猿的我们怎么能错过开发一款我们自己的APP.本人算是一个基于.net的GIS开发入门者(马上就大四啦), 暑假在学校参加GIS比赛有大把 ...
随机推荐
- 使用mitmf 来绕过HSTS站点抓取登陆明文
使用mitmf 来绕过HSTS站点抓取登陆明文 HSTS简介 HSTS是HTTP Strict Transport Security的缩写,即:"HTTP严格安全传输".当浏览器第 ...
- 用web查看hadoop运行状态
转载--http://www.weixuehao.com/archives/621 我们安装完hadoop,下面我们从视觉上看看hadoop怎么玩的. 我们可以在win7系统上,通过web界面,在浏览 ...
- hadoop-cdh with snappy
hadoop: 2.5.0-cdh5.3.6 snappy: 1.1.3 hadoop 2.*不需要hadoop-snappy.只要机器上安装好snappy, 直接编译就可以 编译命令: mvn cl ...
- hihoCoder-1000-A+B
题目描述:传统的A+B题 使用语言:C 代码: #include <stdio.h> int main(void){ int a,b; while((scanf("%d %d&q ...
- NOJ1142-最大连续和
最大连续和 时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 1282 测试通过 : 230 ...
- .Net码农学Android---快速了解数据存储
数据存储 Andoid中的数据存储和我们平时见到的不一样,或者说移动设备的存储和平时不一样.Andoid中的存储方式有五种, 单把存储拎出来,是因为我们后续的开发会经常用到,重要性不言而喻,多样的存储 ...
- Python 爬虫实例
下面是我写的一个简单爬虫实例 1.定义函数读取html网页的源代码 2.从源代码通过正则表达式挑选出自己需要获取的内容 3.序列中的htm依次写到d盘 #!/usr/bin/python import ...
- Mysql允许外网接入
首先你可以为mysql创建一个账户,或者为root用户接入数据库. 授权用户指定所有主机以指定用户连接服务器 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDE ...
- SecurityManager一:理解AccessController.doPrivileged()
AccessController.checkPermission()检测模型: 从VM Stack的current stack frame起逐个检测stack frome所指class的protect ...
- 使用 RestEasy 和 Apache Tomcat 构建 RESTful Web 服务
第一次,用这个RestEasy框架,用的时候,总是提示,404的错误,郁闷,呵呵,不过经过努力,终于解决问题,特别留个标记. 关于404的错误,上网找了一大堆,也还不行. 我感觉应该是lib下面架包的 ...