Java tutorial
//package com.java2s; import android.util.Base64; public class Main { public static String generateToken(String username, String password) { String credentials = username + ":" + password; String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); return "Basic " + base64EncodedCredentials; } }