Base64 is not a strict encryption algorithm, because encryption and decryption algorithms are public.
Base64 's three types of providers:
1.JDK (not recommended)
2.commonsCodes
3.bouncy Castle
Cases:
Import java.io.IOException;
Import Sun.misc.BASE64Decoder;
Import Sun.misc.BASE64Encoder;
public class Base64demo
{
public static void Main (string[] args) throws Exception
{
JDKBASE64 ("Testing test");
COMMONSCODECBASE64 ("Testing test");
BOUNCYCASTLEBASE64 ("Testing test");
}
public static void JdkBase64 (String src) throws IOException
{
Base64encoder encoder = new Base64encoder ();
String encodestr = Encoder.encode (Src.getbytes ());
System.out.println ("Encode:" + encodestr);
Base64decoder decoder = new Base64decoder ();
byte[] Decodebuffer = Decoder.decodebuffer (ENCODESTR);
String decodestr = new string (Decodebuffer);
System.out.println ("decode:" + decodestr);
}
public static void CommonsCodecBase64 (String src)
{
byte[] encodeBase64 = Org.apache.commons.codec.binary.Base64.encodeBase64 (Src.getbytes ());
String encodestr = new string (ENCODEBASE64);
System.out.println ("Encode:" + encodestr);
byte[] decodeBase64 = org.apache.commons.codec.binary.Base64.decodeBase64 (ENCODESTR);
String decodestr = new string (DECODEBASE64);
System.out.println ("decode:" + decodestr);
}
public static void BouncyCastleBase64 (String src)
{
byte[] encodeBase64 = Org.bouncycastle.util.encoders.Base64.encode (Src.getbytes ());
String encodestr = new string (ENCODEBASE64);
System.out.println ("Encode:" + encodestr);
byte[] decodeBase64 = Org.bouncycastle.util.encoders.Base64.decode (ENCODESTR);
String decodestr = new string (DECODEBASE64);
System.out.println ("decode:" + decodestr);
}
}
The Base64 of encryption and decryption algorithm