List of usage examples for android.util Base64 decode
public static byte[] decode(byte[] input, int flags)
From source file:Main.java
static public String decodeToSgtring(byte[] code) { if (code == null || code.length == 0) { return ""; }/*from w w w . j av a 2s . com*/ return new String(Base64.decode(code, Base64.NO_WRAP)); }
From source file:Main.java
/** * Decodes a Base64 string into a Bitmap. Used to decode Bitmaps encoded by * {@link encodeBitmapAsString(Bitmap)}. * @param encodedString the Base64 String to decode. * @return the Bitmap which was encoded by the String. *///w ww . j ava 2s .c om public static Bitmap decodeBitmapFromString(String encodedString) { if (TextUtils.isEmpty(encodedString)) return null; byte[] decoded = Base64.decode(encodedString, Base64.DEFAULT); return BitmapFactory.decodeByteArray(decoded, 0, decoded.length); }
From source file:Main.java
public static String decryptData(String ciphertext, String password) throws Exception { int iterationCount = 100; //because polaroid int keyLength = 256; String[] fields = ciphertext.split("]"); byte[] iv = Base64.decode(fields[0], 0); byte[] salt = Base64.decode(fields[1], 0); byte[] cipherBytes = Base64.decode(fields[2], 0); Log.d(TAG, "ciphertext: " + ciphertext + "\n" + "iv length is " + "\n" + iv.length); KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, iterationCount, keyLength); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); byte[] keyBytes = keyFactory.generateSecret(keySpec).getEncoded(); SecretKey key = new SecretKeySpec(keyBytes, "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); IvParameterSpec ivParams = new IvParameterSpec(iv); cipher.init(Cipher.DECRYPT_MODE, key, ivParams); byte[] plaintext = cipher.doFinal(cipherBytes); String plainStr = new String(plaintext, "UTF-8"); return plainStr; }
From source file:Main.java
private static byte[] base64Decode(byte[] input) { return Base64.decode(input, Base64.NO_WRAP); }
From source file:Main.java
static byte[] decodeB64NP(String s64) { return Base64.decode(s64, Base64.NO_PADDING); }
From source file:Main.java
public static byte[] decodeBase64(byte[] input) { return Base64.decode(input, Base64.DEFAULT); }
From source file:Main.java
public static String base64Decode(String str) { return Base64.decode(str.getBytes(), Base64.DEFAULT).toString(); }
From source file:Main.java
public static String decodeBase64(String s) { return new String(Base64.decode(s, Base64.DEFAULT)); }
From source file:Main.java
/** * Return a byte[] containing the bytes in a given base64 string, or null if this is not a valid * base64 string./* w ww .j a v a 2s.c o m*/ */ public static byte[] getBytesFromBase64(String base64) { try { return Base64.decode(base64, Base64.DEFAULT); } catch (Exception e) { Log.e(LOGTAG, "exception decoding bitmap from data URI: " + base64, e); } return null; }
From source file:Main.java
public static byte[] readByteArrayAttribute(XmlPullParser in, String name) { final String value = in.getAttributeValue(null, name); if (value != null) { return Base64.decode(value, Base64.DEFAULT); } else {// w w w .j a v a 2 s . c om return null; } }