package com.oy;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

import org.junit.Test;

public class demo04 {

    final Base64.Decoder decoder = Base64.getDecoder();
    final Base64.Encoder encoder = Base64.getEncoder();
    
    @Test
    public void testBase64() throws Exception {
        byte[] textByte = "admin:123".getBytes(StandardCharsets.UTF_8);
        String encodedText = encoder.encodeToString(textByte);//编码
        System.out.println(encodedText);//YWRtaW46MTIz
        System.out.println(new String(decoder.decode(encodedText), "UTF-8"));//解码
    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-24
  • 2022-01-22
  • 2021-10-16
  • 2021-10-06
  • 2022-03-07
  • 2022-12-23
相关资源
相似解决方案