Android String Encode encodeCredentials(String username, String password)

Here you can find the source of encodeCredentials(String username, String password)

Description

encode Credentials

Declaration

public static String encodeCredentials(String username, String password) 

Method Source Code

//package com.java2s;

import android.util.Base64;

public class Main {
    public static String encodeCredentials(String username, String password) {
        String cred = username + ":" + password;
        String encodedValue = null;
        byte[] encodedBytes = Base64
                .encode(cred.getBytes(), Base64.NO_WRAP);
        encodedValue = new String(encodedBytes);
        System.out.println("encodedBytes " + new String(encodedBytes));

        byte[] decodedBytes = Base64.decode(encodedBytes, Base64.NO_WRAP);
        System.out.println("decodedBytes " + new String(decodedBytes));

        return encodedValue;

    }/*from  ww  w  .  j  a  va  2 s .  c om*/
}

Related

  1. encode(String s)