Java implements BASE64 bit encryption

Source: Internet
Author: User
Tags base64

A common term for passwords

PlainText: Information to encrypt

Ciphertext: PlainText after being encrypted

Encryption: The process of converting plaintext into ciphertext

Encryption algorithm: conversion algorithm of plaintext to ciphertext

Cryptographic keys: Secret keys for cryptographic operations through cryptographic algorithms

Decryption: The process of converting ciphertext to plaintext

Decryption algorithm: An algorithm for converting ciphertext to plaintext

Decryption key: The secret key of decryption operation through decryption algorithm

Cryptanalysis: Interception of ciphertext attempts to infer the original plaintext or secret key process by analyzing the captured cipher text

Active attack: The attacker illegally invades the password system, using forgery, modification, deletion and other means to inject false messages into the system to deceive (the ciphertext has destructive effect)

Passive attacks: interception of ciphertext and analysis and attack on a security system (no destructive effect on ciphertext)

Cipher system: Consists of five parts, plaintext space, cipher space, secret key space, encryption algorithm and decryption algorithm.

Password protocol: Also known as security protocol, refers to a cryptographic communication protocol based on message exchange, in order to provide a secure service in a network environment.

Kerckhoffs principle: The security of the data is based on the secret of the secret key, not the algorithm, that is, the security of the system depends on the secret key, the secret key is kept secret, and the algorithm is exposed. ___ The basic principles of modern cryptography design

Two password classification password classification----time

Classical Password: The character is the basic encryption unit

Modern Password: Information block as the basic encryption unit

Cryptographic classification----Secret content algorithm
Name Detailed description Application areas Category
Restricted algorithms The secrecy of algorithm based on preserving algorithm Military field Classical code
Based on secret key algorithm Confidentiality of the algorithm based on the secrecy of the secret key Modern password
Password classification----cipher system
Name Alias Detailed description
symmetric password Single-key password or private key password The encryption key is the same as the decryption key
Asymmetric password Dual-key password or public key password Encryption key differs from decryption key, key part public key, private key
Symmetric cipher algorithm Single-key cipher algorithm or private key cipher algorithm A cryptographic, decryption algorithm applied to a symmetric cipher
Asymmetric cryptographic algorithms Two-key cipher algorithm or public-key cipher algorithm A cryptographic, decryption algorithm that corresponds to an asymmetric cipher
Password classification----plaintext processing method

Block password: Refers to the encryption of the clear text into fixed-length groups, with the same secret key and algorithm for each block encryption, output is fixed from the length of the ciphertext, more for network encryption

Stream Password: Also known as serial password. Encrypt one or one byte of plaintext each time it is encrypted

hash function

hash function to verify the integrity of the data

Characteristics:

Unlimited length

Hash values are easy to calculate

Non-reversible hash operation process

hash function-related algorithms

Message digest algorithm MD5, etc.

sha--Secure Hashing algorithm

mac--Message Authentication Code algorithm

Digital signatures

Processed primarily for messages stored in digital form

OSI security system of three OSI and TCP/IP security system

Open communication System (open System interconnection)

      

The security mechanism of seven Layer network communication protocol includes encryption mechanism, digital signature mechanism, access control mechanism, data integrity mechanism, authentication mechanism, service flow filling mechanism, routing control mechanism and notarization mechanism. Each layer will have a different approach

Security services

Authentication (identification): Authentication of the identity and data source of the receiver and sender during the interaction of the entire network

Access control Services: Prevent unauthorized users from accessing resources illegally

Data privacy Services: To ensure that data is safe and effective, preventing data from being compromised and tampered with during transmission

Data integrity Services: Ensure that data is transmitted as-is during transmission

Anti-repudiation service: prevents both sending and receiving parties from denying operations when performing their respective operations

TCP/IP Security system

  

  

Realization of BASE64 algorithm based on four-realization

-jdk

-commons Codec

-bouncy Castle

Code implementation: three ways to implement

 Packagecom.dzj.test;ImportJava.util.Base64.Encoder;ImportSun.misc.BASE64Decoder;Importjava.io.IOException;Importjava.util.Base64;/*** Three ways to implement BASE64 encryption * *@authorAdministrator **/ Public classBase64demo {Private StaticString src = "Hello world";  Public Static voidMain (string[] args) {//jdkBase64 (); //commonsCodesBase64 ();bouncyCastleBase64 (); }     Public Static voidjdkBase64 () {Encoder Encoder=Base64.getencoder (); byte[] encode =Encoder.encode (Src.getbytes ()); String Encodestr=NewString (encode);        System.out.println (ENCODESTR); Base64decoder Decoder=NewBase64decoder (); byte[] Decodebuffer =NULL; Try{Decodebuffer=Decoder.decodebuffer (ENCODESTR); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } String decodestr=NewString (Decodebuffer);    System.out.println (DECODESTR); }     Public Static voidcommonsCodesBase64 () {byte[] Encodebytes =org.apache.commons.codec.binary.Base64.encodeBase64 (Src.getbytes ()); System.out.println ("Encode:" +NewString (encodebytes)); byte[] Decodebytes =org.apache.commons.codec.binary.Base64.decodeBase64 (encodebytes); System.out.println (NewString (decodebytes)); }     Public Static voidbouncyCastleBase64 () {byte[] encode =Org.bouncycastle.util.encoders.Base64.encode (Src.getbytes ()); System.out.println (NewString (encode)); byte[] decode =Org.bouncycastle.util.encoders.Base64.decode (encode); System.out.println (NewString (decode)); }}
View Code

Java implements BASE64 bit encryption

Related Article

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.