BASE64 and decryption of Java Basic encryption

Source: Internet
Author: User
Tags base64 decrypt


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.