跨平台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比赛有大把 ...
随机推荐
- silverlight获取web的url参数
1.网址(如:http://localhost:8081/index.aspx?name=123) 2.获取name=123的信息 3.IDictionary<string,string> ...
- html5制作一个时钟
试着用html5写一个时钟 记得开始这个随笔是几天前,一直保存在草稿里面,一直感觉有个东西搁在在那里,所以今天熬夜也要写完这篇博客!!!哈哈...不多说来上代码和思路. --------------- ...
- js各种宽高(1)
在javascript中操作dom节点让其运动的时候,常常会涉及到各种宽高以及位置坐标等概念,如果不能很好地理解这些属性所代表的意义,就不能理解js的运动原理,同时,由于这些属性概念较多,加上浏览器之 ...
- [译]Memory Reordering Caught in the Act
原文:http://preshing.com/20120515/memory-reordering-caught-in-the-act/ 编写lock-free的C/C++程序时,在保证memory ...
- Eclipse编码问题
通常在Eclipse下,mac和windows编码是不一样的.如果含有中文java sources通常会出现乱码. 解决---小程序! import java.io.File; import java ...
- WIN10系统 Solidworks 2015 Toolbox插件提示 failed to create toolboxl ibrary object 解决方法
网上大部分都是说卸载一个更新程序,但是在WIN10中根本没有. 但是也可通过以下方法解决: 1.关闭SW程序及进程,用管理员命令打开CMD 2.打开并复制SW目录,默认为 C:\Program Fil ...
- jQuery 插件开发解析
那么首先我们来简单的看一下最正统的 jQuery 插件定义方式: (function ($) { $.fn.插件名 = function (settings) { //默认参数 var default ...
- lnmp的使用
命令 1.状态管理 lnmp {start|stop|reload|restart|kill|status} 2.添加虚拟host lnmp vhost add
- 如何从官网下载springframework和document
spring官网 http://spring.io/ --->spring project--->点击github图标 --->artifactory --->进入到了http ...
- android开发系列之git常用命令
最近因为跳槽到新公司,然后新公司里面的代码管理工具是gitLab,所以我想在这篇博客里面整理一下git常用的语法. GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托 ...