Example usage for android.util Base64 NO_WRAP

List of usage examples for android.util Base64 NO_WRAP

Introduction

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

Prototype

int NO_WRAP

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

Click Source Link

Document

Encoder flag bit to omit all line terminators (i.e., the output will be on one long line).

Usage

From source file:Main.java

public static String generateShortUuid() {
    UUID uuid = UUID.randomUUID();
    MessageDigest md = null;/*from w  w w  . j a va2  s .com*/
    try {
        md = MessageDigest.getInstance("SHA-256");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return uuid.toString();
    }

    md.update(uuid.toString().getBytes());
    byte[] digest = md.digest();

    return Base64.encodeToString(digest, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING).substring(0, 20);
}

From source file:Main.java

private static byte[] base64Decode(byte[] input) {
    return Base64.decode(input, Base64.NO_WRAP);
}

From source file:Main.java

public static String encodeToString(String content) {
    try {//from  ww w.j  av  a2s  .com
        return Base64.encodeToString(content.getBytes(), Base64.NO_WRAP);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

public static String makeSHA1HashBase64(byte[] bytes) {
    try {/*www  .j  a va2s.c  o m*/
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        md.update(bytes, 0, bytes.length);
        byte[] sha1hash = md.digest();
        return Base64.encodeToString(sha1hash, Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP);
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

/**
 * Create a temporary filename to store the result of a download.
 * /* w w  w.  j a  va  2s . c  o m*/
 * @param url Name of the URL.
 * @return String containing the temporary filename.
 */
static private String getTemporaryFilename(final String url) {
    // This is what you'd normally call to get a unique temporary
    // filename, but for testing purposes we always name the file
    // the same to avoid filling up student phones with numerous
    // files!
    //
    // return Base64.encodeToString(url.getBytes(),
    //                              Base64.NO_WRAP)
    //                              + System.currentTimeMillis());
    return Base64.encodeToString(url.getBytes(), Base64.NO_WRAP);
}

From source file:Main.java

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

From source file:Main.java

static String encodeB64(byte[] bytes) {
    try {//ww  w  .  j av  a 2s  . c  o  m
        return Base64.encodeToString(bytes, Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP);
    } catch (Exception e) {
    }
    return null;
}

From source file:Main.java

public static String getAuthorizationString() {
    String authorizationString = "Basic " + Base64.encodeToString(
            (PRINT_METRICS_USER_NAME + ":" + PRINT_METRICS_PASSWORD).getBytes(), Base64.NO_WRAP);
    return authorizationString;
}

From source file:Main.java

public static final String getHttpBasicAuthHeader(String username, String password) {
    String digest = username + ":" + password;
    return "Basic " + Base64.encodeToString(digest.getBytes(), Base64.NO_WRAP);
}

From source file:Main.java

public static String _byteArrayToB64(byte[] a) {
    return Base64.encodeToString(a, Base64.NO_WRAP);
}