Base64 { public final static byte[] encodeToByte(byte[] sArr, boolean lineSep) { return encodeToByte(sArr, 0, sArr != null ? sArr.length : 0, lineSep); }  final static byte[] decode(byte[] sArr); final static byte[] decode(byte[] sArr, int sOff, int sLen); final static byte[] decode(char[] sArr); final static byte[] decode(String str); final static byte[] decodeFast(byte[] sArr); final static byte[] decodeFast(char[] sArr); final static byte[] decodeFast(String s); final static byte[] encodeToByte(byte[] sArr, boolean lineSep); final static byte[] encodeToByte(byte[] sArr, int sOff, int sLen, boolean lineSep); final static char[] encodeToChar(byte[] sArr, boolean lineSep); final static String encodeToString(byte[] sArr, boolean lineSep);  }
@Test public void testEncodeToByte() { byte[] bytes = new byte[128]; for (int i = 0; i < 128; i++) { bytes[i] = (byte) i; } byte[] encoded = Base64.encodeToByte(bytes, true); byte[] encodedNoSep = Base64.encodeToByte(bytes, false); String encodedString = Base64.encodeToString(bytes, true); String encodedStringNoSep = Base64.encodeToString(bytes, false); char[] encodedChar = Base64.encodeToChar(bytes, true); char[] encodedCharNoSep = Base64.encodeToChar(bytes, false); byte[] decoded = Base64.decode(encoded); byte[] decodedNoSep = Base64.decode(encodedNoSep); byte[] fastDecoded = Base64.decodeFast(encoded); byte[] fastDecodedNoSep = Base64.decodeFast(encodedNoSep); byte[] decodedString = Base64.decode(encodedString); byte[] decodedStringNoSep = Base64.decode(encodedStringNoSep); byte[] decodedStringFast = Base64.decodeFast(encodedString); byte[] decodedStringFastNoSep = Base64.decodeFast(encodedStringNoSep); byte[] decodedChar = Base64.decode(encodedChar); byte[] decodedCharNoSep = Base64.decode(encodedCharNoSep); byte[] decodedCharFast = Base64.decodeFast(encodedChar); byte[] decodedCharFastNoSep = Base64.decodeFast(encodedCharNoSep); assertFalse(Arrays.equals(encoded, encodedNoSep)); assertEquals(bytes.length, decoded.length); assertEquals(bytes.length, decodedNoSep.length); assertArrayEquals(bytes, decoded); assertArrayEquals(bytes, decodedNoSep); assertArrayEquals(bytes, fastDecoded); assertArrayEquals(bytes, fastDecodedNoSep); assertArrayEquals(bytes, decodedString); assertArrayEquals(bytes, decodedStringNoSep); assertArrayEquals(bytes, decodedStringFast); assertArrayEquals(bytes, decodedStringFastNoSep); assertArrayEquals(bytes, decodedChar); assertArrayEquals(bytes, decodedCharNoSep); assertArrayEquals(bytes, decodedCharFast); assertArrayEquals(bytes, decodedCharFastNoSep); }