package com.smart.base; import org.apache.commons.codec.binary.Base64; public class Base64Test { private static String src = "imooc security base64"; public static void main(String[] args) { // commonsBase64(); bouncyBase64(); } public static void commonsBase64(){ byte[] encodeBytes = Base64.encodeBase64(src.getBytes()); System.out.println("encode:"+new String(encodeBytes)); byte[] decodeBytes = Base64.decodeBase64(encodeBytes); System.out.println(new String(decodeBytes)); } public static void bouncyBase64(){ byte[] encodeBytes = org.bouncycastle.util.encoders.Base64.encode(src.getBytes()); System.out.println(new String(encodeBytes)); byte[] decodeBytes = org.bouncycastle.util.encoders.Base64.decode(encodeBytes); System.out.println(new String(decodeBytes)); } }
时间: 2024-10-28 21:35:35