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);
    }
}

posted on 2017-09-28 16:55  fupeng  阅读(174)  评论(0编辑  收藏  举报

导航