import java.util.Base64; public class Base64Example { public static void main(String[] args) { String originalText = "Hello, Base64!"; byte[] encodedBytes = Base64.getEncoder().encode(originalText.getBytes()); String encodedText = new String(encodedBytes); System.out.println("Encoded text: " + encodedText); byte[] decodedBytes = Base64.getDecoder().decode(encodedText.getBytes()); String decodedText = new String(decodedBytes); System.out.println("Decoded text: " + decodedText); } } Encoded text: SGVsbG8sIEJhc2U2NCE= Decoded text: Hello, Base64!


上一篇:
下一篇:
切换中文