Generate HTTP Basic Authorization Header by base64 encoding - Android File Input Output

Android examples for File Input Output:Base64

Description

Generate HTTP Basic Authorization Header by base64 encoding

Demo Code


//package com.java2s;
import android.util.Base64;

public class Main {
    /**/*w  ww  .  j  a va  2s .com*/
     * Generate HTTP Basic Authorization Header
     * 
     * @param username username
     * @param password password
     * @return Generated header
     */
    public static String getPasswordDigest(String username, String password) {
        String authString = username + ":" + password;
        return Base64.encodeToString(authString.getBytes(), Base64.NO_WRAP);
    }
}

Related Tutorials