if(auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
@Override public String encode(final byte[] data) { return codec.encode(data); } },
public String toString(Object obj) { return base64.encode((byte[]) obj); }
public String convert(byte[] inputData) { return base64Encoder.encode(inputData); }
public String toString(Object obj) { return base64.encode((byte[]) obj); }
public static String byteArrayToBase64(byte[] b) { return new Base64Encoder().encode(b); }
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { writer.setValue(base64.encode((byte[]) source)); }
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { writer.setValue(base64.encode((byte[]) source)); }
public static String base64Encode(byte[] data) { return new Base64Encoder().encode(data); }
public static String getImageHexaBase64(BufferedImage bufferedImage, String imageformat) { //System.out.println("@@@@@@@ IMAGE - getImageHexaBase64 NEW Way @@@@@@"); ByteArrayOutputStream baos = new ByteArrayOutputStream(1000); //"gif" "png" "jpeg" try { ImageIO.write(bufferedImage, imageformat.toString() , baos); baos.flush(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Erro generating Base64 for the image", e); } byte[] resultImageAsRawBytes = baos.toByteArray(); String encodedString = new Base64Encoder().encode(resultImageAsRawBytes); //String encodedString = Base64.encodeBytes(resultImageAsRawBytes); return encodedString; }
public static String getImageHexaBase64(BufferedImage bufferedImage, String imageformat) { //System.out.println("@@@@@@@ IMAGE - getImageHexaBase64 NEW Way @@@@@@"); ByteArrayOutputStream baos = new ByteArrayOutputStream(1000); //"gif" "png" "jpeg" try { ImageIO.write(bufferedImage, imageformat.toString() , baos); baos.flush(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Erro generating Base64 for the image", e); } byte[] resultImageAsRawBytes = baos.toByteArray(); String encodedString = new Base64Encoder().encode(resultImageAsRawBytes); //String encodedString = Base64.encodeBytes(resultImageAsRawBytes); return encodedString; }
public static String streamToBase64(InputStream inputStream) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.io(inputStream, byteArrayOutputStream, true, false); return new Base64Encoder().encode(byteArrayOutputStream.toByteArray()); }
public static String[] makeHttpClientAutorizationHeader(String username, String password) { String un_pd = username + ":" + (password == null ? "" : password); byte[] bytes; try { bytes = un_pd.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new PaxmlRuntimeException(e); } String auth = "Basic " + new Base64Encoder().encode(bytes); return new String[] { "Authorization", auth }; } }
/** * Encrypt with AES algorithm * * @param plaintext Text to encrypt * @param passphrase Password for encryption * @param encoding Encoding * @return Encrypted text */ public String encrypt(String plaintext, String passphrase, String encoding) { if (plaintext.length() == 0) { return null; } try { byte[] iv = generateIV(); Cipher cipher = generateCipher(iv, passphrase, Cipher.ENCRYPT_MODE); if (cipher != null) { byte[] ciphertext = cipher.doFinal(plaintext.getBytes(encoding)); byte[] encrypted = new byte[iv.length + ciphertext.length]; System.arraycopy(iv, 0, encrypted, 0, iv.length); System.arraycopy(ciphertext, 0, encrypted, iv.length, ciphertext.length); return base64Encoder.encode(encrypted); } } catch (IllegalBlockSizeException | BadPaddingException | UnsupportedEncodingException exc) { logger.error("Error encoding string {0}", plaintext, exc); } return null; }
if(auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
if(auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
if(auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
if(auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
auth = "Basic " + new Base64Encoder().encode(auth.getBytes("UTF-8"));
type="binary"; if (input.getValue() !=null) value =base64.encode((byte[]) input.getValue());