Basic Auth

public class BasicAuth {
    public static void main(String[] args) {
        String name = "kidsong";
        String password = "fupeng";

        String authString = name + ":" + password;
        System.out.println("auth string: " + authString);
        byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
        String authStringEnc = new String(authEncBytes);
        System.out.println("Base64 encoded auth string: " + authStringEnc);
    }
}
原文地址:https://www.cnblogs.com/fupeng/p/7607466.html