List of usage examples for android.util Base64 DEFAULT
int DEFAULT
To view the source code for android.util Base64 DEFAULT.
Click Source Link
From source file:Main.java
public static Bitmap stringToBitmap(String string) { Bitmap bitmap = null;/*from w w w . j a v a2 s . c o m*/ try { byte[] bitmapArray; bitmapArray = Base64.decode(string, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length); } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
public static Bitmap convertStringToBitmap(String string) { Bitmap bitmap = null;/*w w w .j a v a 2s .c om*/ try { byte[] bitmapArray; bitmapArray = Base64.decode(string, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length); } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
/** * Decodes base64 string to original//from w w w .j a v a2s. c o m * * @param base64 Base64 string * @return Original string */ public static String fromBase64(String base64) { byte[] data = Base64.decode(base64, Base64.DEFAULT); String origin = new String(data); return origin; }
From source file:Main.java
public static Bitmap getBitmapFromBase64encodedImage(String base64EncodedImage) { byte[] byteArray = Base64.decode(base64EncodedImage, Base64.DEFAULT); Bitmap image = null;/* ww w . ja v a 2 s. c o m*/ try { image = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); } catch (Exception e) { e.printStackTrace(); } return image; }
From source file:Main.java
/** * Metodo che converte la password in Base64 * @param string = password in chiaro// www . 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 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 w w w . ja va 2 s.c o m*/ return str; }
From source file:Main.java
public static String enThunder(String url) { url = "AA" + url + "ZZ"; try {// ww w .j a v a 2s . c o m byte[] bytes = url.getBytes("GBK"); String temp = "" + new String(Base64.encode(bytes, Base64.DEFAULT)); url = ""; char[] base64EncodeChars = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '=' }; for (int i = 0; i < temp.length(); i++) for (int j = 0; j < base64EncodeChars.length; j++) { if ((int) temp.charAt(i) == (int) base64EncodeChars[j]) { url = url + temp.charAt(i); break; } } url = "thunder://" + url; // System.out.println(key); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return url; }
From source file:Main.java
public static String encrypt(String data, String key) throws Exception { try {//from ww w .j a v a2 s. c o m Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); byte[] base64Key = Base64.decode(key, Base64.DEFAULT); SecretKeySpec keyspec = new SecretKeySpec(base64Key, "AES"); cipher.init(Cipher.ENCRYPT_MODE, keyspec); byte[] encrypted = cipher.doFinal(data.getBytes("UTF-8")); return Base64.encodeToString(encrypted, Base64.DEFAULT); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static byte[] encrypt2(byte[] data, String key) throws Exception { try {/*from ww w.j a va 2 s . c om*/ Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); byte[] base64Key = Base64.decode(key, Base64.DEFAULT); SecretKeySpec keyspec = new SecretKeySpec(base64Key, "AES"); cipher.init(Cipher.ENCRYPT_MODE, keyspec); byte[] encrypted = cipher.doFinal(data); return encrypted; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static byte[] desEncrypt(byte[] data, String key) throws Exception { try {/*from ww w . ja va 2s.c o m*/ Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); byte[] base64Key = Base64.decode(key, Base64.DEFAULT); SecretKeySpec keyspec = new SecretKeySpec(base64Key, "AES"); cipher.init(Cipher.DECRYPT_MODE, keyspec); byte[] original = cipher.doFinal(data); return original; } catch (Exception e) { e.printStackTrace(); return null; } }