/** * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 * character blocks * * @param binaryData * binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 * alphabet. * * @param pArray * a byte array containing binary data * @return A byte array containing only Base64 character data */ public byte[] encode(byte[] pArray) { return encodeBase64(pArray, false); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the * output. The url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. * @since 1.4 */ public static byte[] encodeBase64URLSafe(final byte[] binaryData) { return encodeBase64(binaryData, false, true); }
/** * Encodes binary data using the base64 algorithm but does not chunk the output. * * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. */ public static byte[] encodeBase64(final byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 * character blocks * * @param binaryData * binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(final byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes binary data using the base64 algorithm but does not chunk the output. * * @param binaryData * binary data to encode * @return Base64 characters */ public static byte[] encodeBase64(byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 * alphabet. * * @param pArray * a byte array containing binary data * @return A byte array containing only Base64 character data */ public byte[] encode(byte[] pArray) { return encodeBase64(pArray, false); }
/** * Encodes binary data using the base64 algorithm but does not chunk the output. * * @param binaryData * binary data to encode * @return Base64 characters */ public static byte[] encodeBase64(byte[] binaryData) { return encodeBase64(binaryData, false); }
/** * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 * character blocks * * @param binaryData * binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(byte[] binaryData) { return encodeBase64(binaryData, true); }
/** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 * character blocks. * * @param binaryData * Array containing binary data to encode. * @param isChunked * if <code>true</code> this encoder will chunk the base64 output into 76 character * blocks * @return Base64-encoded data. * @throws IllegalArgumentException * Thrown when the input array needs an output array bigger than * {@link Integer#MAX_VALUE} */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { return encodeBase64(binaryData, isChunked, false); }
/** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 * character blocks. * * @param binaryData * Array containing binary data to encode. * @param isChunked * if <code>true</code> this encoder will chunk the base64 output into 76 character * blocks * @param urlSafe * if <code>true</code> this encoder will emit - and _ instead of the usual + and / * characters. * @return Base64-encoded data. * @throws IllegalArgumentException * Thrown when the input array needs an output array bigger than * {@link Integer#MAX_VALUE} * @since 1.4 */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE); }
/** * Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF. * * @param binaryData * binary data to encode * @return String containing Base64 characters. * @since 1.4 */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, true)); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the * output. The url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true)); }
/** * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature * * @param bigInt * a BigInteger * @return A byte array containing base64 character data * @throws NullPointerException * if null is passed in * @since 1.4 */ public static byte[] encodeInteger(final BigInteger bigInt) { if (bigInt == null) { throw new NullPointerException("encodeInteger called with null parameter"); } return encodeBase64(toIntegerBytes(bigInt), false); }