Sun.misc. Base64encoder The /base64decoder class is not part of the JDK standard library category, but it is included in the JDK and can be used directly, but this does not have Java doc, which is not a recommended tool class in the JDK. It is highly recommended not to use Sun.misc, which is not safe.
Bouncycastle jar Package:http://www.bouncycastle.org/latest_releases.html
Package Com.tvm.mrz.security.base64;import Java.io.ioexception;import org.apache.commons.codec.binary.Base64; Import Sun.misc.base64decoder;import Sun.misc.base64encoder;public class Base64test {private static String src = "Mr.Z Se Curity Base64 ";p ublic static void JdkBase64 () {Base64encoder encoder = new Base64encoder (); String encode = Encoder.encode (Src.getbytes ()); System.out.println ("Encode:" + encode); Base64decoder decoder = new Base64decoder (); try {byte[] decode = decoder.decodebuffer (encode); System.out.println ("Decode:" + new String (decode));} catch (IOException e) {e.printstacktrace ();}} public static void CommonsCodecBase64 () {//String encode = base64.encodebase64string (Src.getbytes ()); byte[] encode = Ba Se64.encodebase64 (Src.getbytes ()); System.out.println ("Encode:" + new String (encode)); byte[] decode = base64.decodebase64 (encode); System.out.println ("Decode:" + new String (decode));} public static void BouncyCastleBase64 () {byte[] encode = org.bouncycastle.uTil.encoders.Base64.encode (Src.getbytes ()); System.out.println ("Encode:" + new String (encode)); byte[] decode = Org.bouncycastle.util.encoders.Base64.decode (Enco DE); System.out.println ("Decode:" + new String (decode));} public static void Main (string[] args) {jdkBase64 (); CommonsCodecBase64 (); BouncyCastleBase64 ();}}
Java Encryption Series (II) BASE64 encryption