java 1.8中引入了Base64,不在需要引入第三方库就可以使用base64了。

java8 base64使用

在需要用到base64进行加密解密的时候就可以使用了

     String text = "base64 in java8 lib";
        //编码
        String encode = Base64.getEncoder()
                .encodeToString(text.getBytes(StandardCharsets.UTF_8));
        System.out.println(encode);

        //解码
        String decode = new String(Base64.getDecoder().decode(encode), StandardCharsets.UTF_8);
        System.out.println(decode);

 

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2021-10-23
  • 2021-09-18
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2021-07-29
  • 2021-07-12
  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案