/** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. * * @param source The data to convert * @since 1.4 * @return Encoded string. */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @since 1.4 * @return Encoded string. */ public static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, NO_OPTIONS); } // end encodeBytes
/** * Encodes a byte array into Base64 notation. * <p/> * Valid options:<pre> * GZIP: gzip-compresses object before encoding it. * DONT_BREAK_LINES: don't break lines at 76 characters * <i>Note: Technically, this makes your encoding non-compliant.</i> * </pre> * <p/> * Example: <code>encodeBytes( myData, Base64.GZIP )</code> or * <p/> * Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )</code> * * @param source The data to convert * @param options Specified options * @see Base64#GZIP * @see Base64#DONT_BREAK_LINES * @since 2.0 * @return Encoded string. */ public static String encodeBytes(byte[] source, int options) { return encodeBytes(source, 0, source.length, options); } // end encodeBytes
public static String encrypt(String string) throws Exception { byte[] utf8 = string.getBytes("UTF8"); // Encrypt byte[] enc = ecipher.doFinal(utf8); return Base64.encodeBytes(enc); }
String fileName = Base64.encodeBytes(jid.toString().getBytes());
String fileName = Base64.encodeBytes(jid.toString().getBytes());