List of utility methods to do Base64 Encode
String | toBase64(byte[] aValue) Convert a byte array into a Base64 string (as used in mime formats) final String m_strBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int byte1; int byte2; int byte3; int iByteLen = aValue.length; StringBuffer tt = new StringBuffer(); for (int i = 0; i < iByteLen; i += 3) { boolean bByte2 = (i + 1) < iByteLen; ... |
byte[] | toBase64(byte[] buf, int start, int length) to Base byte[] tmp = new byte[length * 2]; int i, j, k; int foo = (length / 3) * 3 + start; i = 0; for (j = start; j < foo; j += 3) { k = (buf[j] >>> 2) & 0x3f; tmp[i++] = b64[k]; k = (buf[j] & 0x03) << 4 | (buf[j + 1] >>> 4) & 0x0f; ... |
String | toBase64(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); ... |
String | toBase64(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); ... |
String | toBase64(final byte[] bytes) Converts the byte array into a Base64 (RFC 2045) string. final int length = bytes.length; final StringBuffer result = new StringBuffer(4 * ((length + 2) / 3)); int index = 0; final int numGroups = length / 3; for (int i = 0; i < numGroups; i++) { final int byte0 = bytes[index++] & 0xff; final int byte1 = bytes[index++] & 0xff; final int byte2 = bytes[index++] & 0xff; ... |
String | toBase64(final byte[] value) Convert byte array to Base64 string. StringBuilder str = new StringBuilder((value.length * 4) / 3); int b; for (int pos = 0; pos < value.length; pos += 3) { b = (value[pos] & 0xFC) >> 2; str.append(BASE_64_ARRAY[b]); b = (value[pos] & 0x03) << 4; if (pos + 1 < value.length) { b |= (value[pos + 1] & 0xF0) >> 4; ... |
String | toBase64(final String str) Convert a String into its base64 representation. final String res64 = Base64.getEncoder().encodeToString(str.getBytes()); return (res64); |
String | toBase64(int x) to Base char[] b64 = new char[6]; b64[5] = encodeLookup[x & 63]; x >>>= 6; b64[4] = encodeLookup[x & 63]; x >>>= 6; b64[3] = encodeLookup[x & 63]; x >>>= 6; b64[2] = encodeLookup[x & 63]; ... |
String | toBase64(long num) Encode number to base64 (based on http://www.ietf.org/rfc/rfc2045.txt Table 1) return toBase(num, BASE64_CHARS);
|
String | toBase64(long value) Return an optionally single-quoted string containing a base-64 encoded version of the given long value. int low = (int) (value & 0xffffffff); int high = (int) (value >> 32); StringBuilder sb = new StringBuilder(); boolean haveNonZero = base64Append(sb, (high >> 28) & 0xf, false); haveNonZero = base64Append(sb, (high >> 22) & 0x3f, haveNonZero); haveNonZero = base64Append(sb, (high >> 16) & 0x3f, haveNonZero); haveNonZero = base64Append(sb, (high >> 10) & 0x3f, haveNonZero); haveNonZero = base64Append(sb, (high >> 4) & 0x3f, haveNonZero); ... |