Example usage for android.util Base64 encodeToString

List of usage examples for android.util Base64 encodeToString

Introduction

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

Prototype

public static String encodeToString(byte[] input, int flags) 

Source Link

Document

Base64-encode the given data and return a newly allocated String with the result.

Usage

From source file:Main.java

public static String bitmap2PNGBase64(Bitmap bitmap) {
    return Base64.encodeToString(bitmap2PNGByteArray(bitmap), Base64.DEFAULT);
}

From source file:Main.java

public static String generateToken(String username, String password) {
    String credentials = username + ":" + password;
    String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
    return "Basic " + base64EncodedCredentials;
}

From source file:Main.java

@NonNull
public static String getBasicAuthorizationHeaderContent(String login, String password) {
    return "Basic " + Base64.encodeToString((login + ":" + password).getBytes(), Base64.NO_WRAP);
}

From source file:Main.java

public static String encodeBase64(String str, String charset, int flags) throws UnsupportedEncodingException {
    return Base64.encodeToString(str.getBytes(charset), flags);
}

From source file:Main.java

public static String createAuthorizationString(String username, String password) {

    String usernamePassword = username + ":" + password;

    return "Basic " + Base64.encodeToString(usernamePassword.getBytes(), Base64.NO_WRAP);
}

From source file:Main.java

public static String createBasicAuthToken(String username, String password) {
    String credentials = username + ":" + password;
    String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
    final String token = "Basic " + base64EncodedCredentials;
    return token;
}

From source file:Main.java

public static String base64Encode(String strBase64, String code) throws UnsupportedEncodingException {
    String enToStr = Base64.encodeToString(strBase64.getBytes(), Base64.DEFAULT);
    //      String string = new String(Base64.encode(strBase64.getBytes(code), Base64.DEFAULT));
    return enToStr;
}

From source file:Main.java

/**
 * Converts byte array to String/*from  ww  w  . j a  va  2s .c o m*/
 * @param arr - The array to be encoded
 * @return - The returned String
 */
public static String encode(byte[] arr) {
    return Base64.encodeToString(arr, Base64.DEFAULT);
}

From source file:Main.java

static public String encodeToString(String code) {
    if (code == null || code.length() == 0) {
        return "";
    }/*w w w  . ja v  a2  s. com*/
    return Base64.encodeToString(code.getBytes(), Base64.NO_WRAP);
}

From source file:Main.java

public static String encodeBase64(String str) throws UnsupportedEncodingException, Base64DataException {
    return Base64.encodeToString(str.getBytes("UTF-8"), Base64.DEFAULT).replace("\n", "");
}