Android Utililty Methods Base64 Byte Array Encode

List of utility methods to do Base64 Byte Array Encode

Description

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

Method

Stringbase64(byte[] target)
base
String temp = android.util.Base64.encodeToString(target, 0);
return temp.replace('+', '-').replace('/', '_');
StringtoBase64(byte[] data)
Converts a byte array into a base 64 encoded string.
if (data == null) {
    return null;
int len = data.length;
if (len == 0) {
    return "";
int olen = 4 * ((len + 2) / 3);
...
char[]encodeBlock(byte raw[], int offset)
encode Block
int block = 0;
int slack = raw.length - offset - 1;
int end = slack < 2 ? slack : 2;
for (int i = 0; i <= end; i++) {
    byte b = raw[offset + i];
    int neuter = b >= 0 ? ((int) (b)) : b + 256;
    block += neuter << 8 * (2 - i);
char base64[] = new char[4];
for (int i = 0; i < 4; i++) {
    int sixbit = block >>> 6 * (3 - i) & 0x3f;
    base64[i] = getChar(sixbit);
if (slack < 1) {
    base64[2] = '=';
if (slack < 2) {
    base64[3] = '=';
return base64;