Java tutorial
//package com.java2s; import android.util.Base64; public class Main { 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; } }