Cross-platform base64 data transfer attention issues

Source: Internet
Author: User

Today, using Base64 encoding to transfer JSON strings, the Android side never see the picture!

First, we find that the length of JSON string received by Android is inconsistent, and the JSON data received by Android is filtered out by the "/" and "+" in the server data.

View data discovery before using: New Base64encoder (). Encode (bytes) to turn byte[].

Cross-platform transfer Base64 encoded data is used: base64.encodebase64urlsafestring (bytes) (method meaning: Encode binary data using Base64 algorithm with URL security change but not block output).

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 the "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 character blocks.
static byte[] encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe)Encodes binary data using the Base64 algorithm, optionally chunking the output into 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 character blocks.
static byte[] encodeBase64Chunked(byte[] binaryData)Encodes binary data using the Base64 algorithm and chunks the encoded output into 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 an integer according to crypto standards such as a "s xml-signature
static boolean isArrayByteBase64(byte[] arrayOctet)Deprecated. 1.5 Use isBase64(byte[]) , would be is removed in 2.0.
static boolean isBase64(byte octet)Returns whether or not, in the octet base, 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 are in the octet Base64 alphabet.
boolean isUrlSafe()Returns our current encode mode.

Cross-platform base64 data transfer attention issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.