List of utility methods to do Base64 Encode
String | base64Encode(byte[] aData) Encodes the given byte[] using the Base64-encoding, as specified in RFC-2045 (Section 6.8). if (aData == null || aData.length == 0) throw new IllegalArgumentException("Can not encode NULL or empty byte array."); byte encodedBuf[] = new byte[(aData.length + 2) / 3 * 4]; int srcIndex, destIndex; for (srcIndex = 0, destIndex = 0; srcIndex < aData.length - 2; srcIndex += 3) { encodedBuf[destIndex++] = mBase64EncMap[aData[srcIndex] >>> 2 & 077]; encodedBuf[destIndex++] = mBase64EncMap[aData[srcIndex + 1] >>> 4 & 017 | aData[srcIndex] << 4 & 077]; encodedBuf[destIndex++] = mBase64EncMap[aData[srcIndex + 2] >>> 6 & 003 ... |
String | base64Encode(byte[] aData) Codifica um dado array de bytes usando codificacao Base64 como especificado na RFC-2045 (sessao 6.8) if ((aData == null) || (aData.length == 0)) throw new IllegalArgumentException("Can not encode NULL or empty byte array."); byte encodedBuf[] = new byte[((aData.length + 2) / 3) * 4]; int srcIndex, destIndex; for (srcIndex = 0, destIndex = 0; srcIndex < aData.length - 2; srcIndex += 3) { encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] >>> 2) & 077]; encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex + 1] >>> 4) & 017 | (aData[srcIndex] << 4) & 077]; ... |
String | base64Encode(byte[] buf) Traduce un Arreglo de bytes a un String en Base64 int size = buf.length; char[] ar = new char[((size + 2) / 3) * 4]; int a = 0; int i = 0; while (i < size) { byte b0 = buf[i++]; byte b1 = (i < size) ? buf[i++] : 0; byte b2 = (i < size) ? buf[i++] : 0; ... |
String | base64Encode(byte[] buf, int tw) Base64 encode a byte array, returning the returning string. int srcLength = buf.length; byte[] input = new byte[3]; int[] output = new int[4]; StringBuffer out = new StringBuffer(); int i = 0; int chars = 0; while (srcLength > 2) { input[0] = buf[i++]; ... |
String | base64Encode(byte[] bytes) Base64 encodes the supplied bytes array, using the standard base 64 encoding algorithm. int i = 0; int bytesToWrite = bytes.length; StringBuilder buff = new StringBuilder(bytes.length * 4 / 3); while (bytesToWrite >= 3) { buff.append(sCharLookup[(bytes[i] >>> 2) & 63]); buff.append(sCharLookup[((bytes[i] & 3) << 4) + ((bytes[i + 1] >>> 4) & 15)]); buff.append(sCharLookup[((bytes[i + 1] & 15) << 2) + ((bytes[i + 2] >>> 6) & 3)]); buff.append(sCharLookup[bytes[i + 2] & 63]); ... |
String | base64Encode(byte[] bytes) Base64 encodes a byte array. if (bytes == null) { throw new IllegalArgumentException("Input bytes must not be null."); if (bytes.length >= BASE64_UPPER_BOUND) { throw new IllegalArgumentException("Input bytes length must not exceed " + BASE64_UPPER_BOUND); int triples = bytes.length / 3; if (bytes.length % 3 != 0) { ... |
String | base64Encode(byte[] bytes) Encodes the specified byte array into a String using the Base64 encoding scheme String hashString = Base64.getEncoder().encodeToString(bytes);
return hashString;
|
String | base64encode(byte[] bytes) baseencode int current = 0; int state = 0; StringBuilder sb = new StringBuilder(); for (byte b : bytes) { switch (state) { case 0: sb.append(b64table[(b & 0b11111100) >>> 2]); current = (b & 0b00000011) << 4; ... |
String | base64encode(byte[] data) Base64 Encode an array of bytes char[] tbl = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; StringBuilder buffer = new StringBuilder(); int pad = 0; for (int i = 0; i < data.length; i += 3) { int b = ((data[i] & 0xFF) << 16) & 0xFFFFFF; ... |
String | base64Encode(byte[] data) base Encode StringBuilder sb = new StringBuilder(); int r = data.length % 3; int len = data.length - r; int i = 0; int c; while (i < len) { c = (0x000000ff & data[i++]) << 16 | (0x000000ff & data[i++]) << 8 | (0x000000ff & data[i++]); sb.append(base64EncodeChars[c >> 18]); ... |