代码
package com.gzt.security.browser.controller;
import org.apache.commons.codec.binary.Base64;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.misc.BASE64Encoder;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@RestController
public class TestController {
/**
* BASE64编码
*/
public String encryptBASE64(String username,String password) {
byte[] key = (username+":"+password).getBytes();
return new String(Base64.encodeBase64(key));
}
@GetMapping("/demo")
public void test(){
String account = "username";