Example usage for android.util Base64 URL_SAFE

List of usage examples for android.util Base64 URL_SAFE

Introduction

In this page you can find the example usage for android.util Base64 URL_SAFE.

Prototype

int URL_SAFE

To view the source code for android.util Base64 URL_SAFE.

Click Source Link

Document

Encoder/decoder flag bit to indicate using the "URL and filename safe" variant of Base64 (see RFC 3548 section 4) where - and _ are used in place of + and / .

Usage

From source file:Main.java

public static byte[] decodeBase64FromUrlSafe(String content) {
    int flags = Base64.URL_SAFE;
    return Base64.decode(content, flags);
}

From source file:Main.java

public static String base64Encode(String msg) {
    return Base64.encodeToString(msg.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}

From source file:Main.java

public static byte[] decode(byte[] bytes) {
    return Base64.decode(bytes, Base64.URL_SAFE);
}

From source file:Main.java

public static String getB64Auth(String login, String pass) {
    String source = login + ":" + pass;
    String ret = "Basic " + Base64.encodeToString(source.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
    return ret;/*from   w w  w.j  a va 2  s  . co  m*/
}

From source file:Main.java

public static String base64Encode(byte[] in) {
    String encoded = null;//from   www .  j a  v a 2 s . c  o  m
    try {
        encoded = new String(Base64.encode(in, Base64.URL_SAFE | Base64.NO_PADDING), "UTF8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return encoded;
}

From source file:Main.java

public static byte[] base64UrlDecode(String arg) {
    return Base64.decode(arg, Base64.URL_SAFE | Base64.NO_WRAP);
}

From source file:Main.java

public static byte[] decode(String string) {
    return Base64.decode(string, Base64.URL_SAFE);
}

From source file:Main.java

public static String base64UrlEncode(byte[] arg) {
    return Base64.encodeToString(arg, 0, arg.length, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
}

From source file:Main.java

/**
 * @param login login name/*  ww  w .j a  va2s.  com*/
 * @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

/**
 * decode from a base64 to a bitmap/*from   ww  w.  j  ava2  s.c o  m*/
 * 
 * @param base64
 * @return
 */
public static Bitmap decodeFromBase64(String base64) {
    byte[] bitmapArray = Base64.decode(base64, Base64.NO_WRAP | Base64.URL_SAFE);
    return BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
}