BASE64 decryption, encryption and decryption actually refers to the encoding (encode) and decoding (decode) process, its transformation is very simple, only to avoid the information is directly recognized.
The Base64 content delivery code is designed to describe a 8-bit byte of any sequence as a form that is not easy to be recognized directly.
Base64 uses the 64 characters of a--z,a--z,0--9,+,/.
Base64 is a very common coding specification that converts binary sequences into human-readable ASCII character sequences
Base64 Coding table
Value Encoding value Encoding value Encoding value Encoding
0 A + R i-Z
1 B S and J 52 0
2 C T-K 53 1
3 D U PNS L 54 2
4 E V M 55 3
5 F N 56 4
6 G X 57 5
7 H x P 58 6
8 I Z-Q 59 7
9 J 60 8
Ten K B (s) 61 9
L-C-T 62 +
63 M/D
N-e-v(pad) =
-O-F-W
P. g x
Q, H, y
package com.encryption;import java.io.unsupportedencodingexception;import Sun.misc.base64decoder;import sun.misc.base64encoder;/** *base64 and decryption * @author roger */@SuppressWarnings ("restriction") public class base64util {public static void main (String[] args) {String key = "123456789"; string encrypt = ""; Try {encrypt = base64util.encryptbase64 (Key.getBytes ("UTF-8" )); System.out.println ("encrypt : " +encrypt); catch (unsupportedencodingexception e) {e.printstacktrace ();} catch (exception e) {e.printstacktrace ();} Try {byte[] decrypt = base64util.decryptbase64 (encrypt); System.out.println ("decrypt : " +new string (decrypt, "UTF-8"));} catch (exception e) {e.printstacktrace ();}} /** * for BASE64 encryption (encoding) * * @param key * PlusSecret characters * @return * character encryption byte[] * @throws Exception */public Static byte[] decryptbase64 (String key) throws Exception {return (new Base64decoder ()). Decodebuffer (key);} /** * BASE64 Decrypt (decode) * * @param key * Decrypt characters byte[] * @ return * after decryption string * @throws Exception */public static String EncryptBASE64 (Byte[] key) throws Exception {return (New base64encoder ()). Encodebuffer (key);}}
BASE64 and decryption of Java Basic encryption