import java.util.Base64;

public class Test {
	public static void main(String[] args) throws UnsupportedEncodingException {
					// 要加密的字符串
					String pwd = "12345678";
					// 加密
					String encodeToString = Base64.getEncoder().encodeToString(pwd.getBytes("UTF-8"));
					System.out.println(encodeToString);// MTIzNDU2Nzg=
					// 解密
					String decodeToString = new String(Base64.getDecoder().decode(encodeToString.getBytes()), "UTF-8");
					System.out.println(decodeToString);// 12345678
			}
}