Android Utililty Methods Byte Array Encode

List of utility methods to do Byte Array Encode

Description

The list of methods to do Byte Array Encode are organized into topic(s).

Method

StringencodeWebSafe(byte[] source, boolean doPadding)
Encodes a byte array into web safe Base64 notation.
return encode(source, 0, source.length, WEBSAFE_ALPHABET, doPadding);
StringencodeWebSafe(byte[] source, boolean doPadding)
Encodes a byte array into web safe Base64 notation.
return encode(source, 0, source.length, WEBSAFE_ALPHABET, doPadding);
byte[]encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options)
Encodes up to the first three bytes of array threeBytes and returns a four-byte array in Base64 notation.
encode3to4(threeBytes, 0, numSigBytes, b4, 0, options);
return b4;
byte[]encode3to4(byte[] source, int srcOffset, int numSigBytes, byte[] destination, int destOffset, int options)

Encodes up to three bytes of the array source and writes the resulting four Base64 bytes to destination.

byte[] ALPHABET = getAlphabet(options);
int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8)
        : 0)
        | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16)
                : 0)
        | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24)
                : 0);
switch (numSigBytes) {
...
voidputChar(byte[] bb, char ch, int index)
put Char
int temp = (int) ch;
for (int i = 0; i < 2; i++) {
    bb[index + i] = new Integer(temp & 0xff).byteValue(); 
    temp = temp >> 8; 
voidputDouble(byte[] bb, double x, int index)
put Double
long l = Double.doubleToLongBits(x);
for (int i = 0; i < 8; i++) {
    bb[index + i] = new Long(l).byteValue();
    l = l >> 8;
voidputInt(int value, int offset, byte[] byteArr)
put Int
byteArr[offset + 0] = (byte) (value >>> 24);
byteArr[offset + 1] = (byte) (value >>> 16);
byteArr[offset + 2] = (byte) (value >>> 8);
byteArr[offset + 3] = (byte) (value >>> 0);
voidputInts(int[] fromInts, byte[] toBytes)
put Ints
for (int intInd = 0; intInd < fromInts.length; ++intInd) {
    putInt(fromInts[intInd], intInd * INT_SIZE, toBytes);
voidputLong(byte[] bb, long x, int index)
put Long
bb[index + 0] = (byte) (x >> 56);
bb[index + 1] = (byte) (x >> 48);
bb[index + 2] = (byte) (x >> 40);
bb[index + 3] = (byte) (x >> 32);
bb[index + 4] = (byte) (x >> 24);
bb[index + 5] = (byte) (x >> 16);
bb[index + 6] = (byte) (x >> 8);
bb[index + 7] = (byte) (x >> 0);
...
byte[]putOrCopyString(String fromString, byte[] toBytes)
put Or Copy String
byte[] fromBytes;
try {
    fromBytes = fromString.getBytes(BYTE_CHARSET);
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e);
if (toBytes.length == fromBytes.length) {
    System.arraycopy(fromBytes, 0, toBytes, 0, fromBytes.length);
...