Android Utililty Methods Base64 Encode

List of utility methods to do Base64 Encode

Description

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

Method

Stringbase64Encode(final byte[] data)
base Encode
String res = null;
try {
    res = new String(Base64.encodeBase64(data));
} catch (Exception e) {
    e.printStackTrace();
return res;
Stringencode(byte[] src)
encode
return Base64.encodeToString(src, Base64.DEFAULT);
Stringto64(String a)
to
return Base64.encodeToString(a.getBytes(), Base64.DEFAULT);
StringtoBase64(byte[] barray)
to Base
if (barray == null) {
    return "";
String result;
result = Base64.encodeToString(barray, MAGNET_BASE64_FLAGS);
return result;
StringencodeBase64(byte abyte0[])
encode Base
if (abyte0 == null)
    return "";
char ac[] = new char[4 * ((2 + abyte0.length) / 3)];
int i = 0;
for (int j = 0; j < -2 + abyte0.length; j += 3) {
    int k2 = ((0xff & abyte0[j]) << 16)
            + ((0xff & abyte0[j + 1]) << 8)
            + (0xff & abyte0[j + 2]);
...
StringencodeBase64(String input)
Encodes a string with Base64
byte[] data = input.getBytes("UTF-8");
return Base64.encodeToString(data, Base64.DEFAULT);
StringencryptToBase64Text(String key, String src)
encrypt To Base Text
byte[] result = encryptToBytes(key, src);
return new String(Base64.encode(result, Base64.DEFAULT));
StringgenerateBase64String(String inString)
generate Base String
byte[] byteTransform = inString.getBytes("UTF-8");
return Base64.encodeToString(byteTransform, Base64.NO_WRAP);
byte[]ImageBase64Decode(String base64_str)
Image Base64 Decode
byte[] b = Base64.decode(base64_str, Base64.DEFAULT);
for (int i = 0; i < b.length; i++) {
    if (b[i] < 0) {
        b[i] += 256;
return b;
StringlongKeyId2Base64String(long keyId)
long Key Id Base String
try {
    return new String(Base64.encode(
            ByteBuffer.allocate(Long.SIZE / 8).putLong(keyId)
                    .array(), Base64.NO_WRAP), "UTF-8");
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
    return null;