List of usage examples for android.util Base64 encodeToString
public static String encodeToString(byte[] input, int flags)
From source file:Main.java
public static String convertBase64(String str) { byte[] data;/*from ww w .ja va2 s. c o m*/ try { data = str.getBytes("UTF-8"); String base64 = Base64.encodeToString(data, Base64.DEFAULT); return base64.trim(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }
From source file:Main.java
/** * Encodes input string to Base64/*from w w w. j av a2s . c o m*/ * * @param input Input string * @return Base64 string */ public static String toBase64(String input) { String base64Str = Base64.encodeToString(input.getBytes(), Base64.NO_WRAP); return base64Str; }
From source file:Main.java
/** * @param login login name/*from www . ja va 2 s. c om*/ * @param pass password * @return Base64 Auth encoded string */ static String getB64Auth(String login, String pass) { String source = login + ":" + pass; return "Basic " + Base64.encodeToString(source.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP); }
From source file:Main.java
public static String base64Encode(String phone, String str) { int times = Integer.parseInt(phone.substring(0, 10)) % 4 + 2; for (int i = 0; i < times; i++) { str = Base64.encodeToString(str.getBytes(), Base64.DEFAULT); }//from www .ja va 2 s . c om return str; }
From source file:Main.java
/** * Metodo che converte la password in Base64 * @param string = password in chiaro//from w w w . j a v a 2 s.co m * @return password cifrata */ public static String encodePassword(String string) { byte[] data = string.getBytes(); return Base64.encodeToString(data, Base64.DEFAULT); }
From source file:Main.java
public static String encodeToString(Bitmap bitmap) { if (bitmap == null) { return ""; }/* www .j av a2 s. c om*/ return Base64.encodeToString(encodeToBytes(bitmap), Base64.DEFAULT); }
From source file:Main.java
public static String encode(String plain, Charset charset) { return Base64.encodeToString(plain.getBytes(charset), Base64.DEFAULT); }
From source file:Main.java
public static String generateBase64String(String inString) throws UnsupportedEncodingException { byte[] byteTransform = inString.getBytes("UTF-8"); return Base64.encodeToString(byteTransform, Base64.NO_WRAP); }
From source file:Main.java
public static String convertBitmapToBase64(Bitmap bitmap) { final int size = bitmap.getByteCount(); ByteBuffer dst = ByteBuffer.allocate(size); bitmap.copyPixelsToBuffer(dst);// ww w . j a va 2 s . c o m return Base64.encodeToString(dst.array(), Base64.DEFAULT); }
From source file:Main.java
public static String bytesToBinary(File file) { String fileStr = ""; try {//from w w w.j av a 2 s . co m byte[] bts = getFileBytes(file); fileStr = Base64.encodeToString(bts, Base64.DEFAULT); } catch (Exception e) { // TODO: handle exception } return fileStr; }