Base64 for Information Encryption and base64 for encryption

Source: Internet
Author: User

Base64 for Information Encryption and base64 for encryption

Base64 is the simplest and simplest form of encryption. It is often used and recorded for further understanding.

Jdk format:

// Obtain the key
Base64Encoder encoder = new Base64Encoder ();
// Encrypted String encoder_jdk = encoder. encode (src. getBytes (); System. out. println ("encoder:" + encoder );
// Decrypt
Byte [] decode_jdk = encoder. decode (encoder_jdk); System. out. print (decode_jdk );

CommonsCodes format:

Using commonsCodesBase64 encryption requires adding a jar package: commons-codec-1.10.jar

Public static void commonsCodesBase64 () {// encrypt byte [] encode_cc = org. apache. commons. codec. binary. base64.encodeBase64 (src. getBytes (); System. out. println ("encode:" + encode_cc); // decrypt byte [] decode_cc = org. apache. commons. codec. binary. base64.decodeBase64 (encode_cc); System. out. println ("decode:" + new String (decode_cc ));}

BouncyCastle format:

Using bouncyCastleBase64 encryption requires adding a jar package: bcprov-jdk15on-149.jar

Public static void bouncyCastleBase64 () {// encrypted byte [] encode_bc = org. bouncycastle. util. encoders. base64.encode (src. getBytes (); System. out. println ("encode:" + encode_bc); // decrypt byte [] decode_bc = org. bouncycastle. util. encoders. base64.decode (encode_bc); System. out. println ("decode:" + new String (decode_bc ));}

The conclusion is very simple and there is no technical content. I am very interested in information security. I would be very grateful if anyone could kindly advise me! (Mailbox: 1453296946@qq.com)

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.