Several algorithms of Java symmetric encryption are implemented respectively

Java symmetric encryption is implemented using DES / 3DES / AES algorithms

There are two sentences:

1) Algorithms and data structures are an important part of programming. If you lose algorithms and data structures, you lose everything.

2) Programming is algorithm and data structure. Algorithm and data structure are the soul of programming.

Note that this is not what I said, but the summary of countless programmers. What I said is very real and incisive. It is necessary to study more algorithms for long-term sustainable development. Today, I will tell you about the symmetric encryption algorithm in the encryption algorithm, and here I will teach you the programming and use of symmetric encryption algorithm. Including DES, 3DES and AES three symmetric encryption algorithm programming, full of dry goods.

1. Symmetric cryptographic algorithm

Symmetric cryptographic algorithm is the most widely used and frequently used encryption algorithm. It is not only used in the software industry, but also popular in the hardware industry. Symmetric encryption algorithm will be given priority when various infrastructures involve security requirements.

The encryption key and decryption key of symmetric cipher algorithm are the same. For most symmetric cipher algorithms, the encryption and decryption processes are inverse to each other.

(1) Encryption and decryption communication model

(2) Features: open algorithm, small amount of calculation, fast encryption speed and high encryption efficiency

(3) Weakness: both parties use the same key, and the security is not guaranteed

Symmetric ciphers include stream ciphers and block ciphers, but block ciphers are widely used now:

(4) Block cipher working mode

1) ECB: electronic codebook (most commonly, each encryption generates an independent ciphertext group, and will not affect other ciphertext groups, that is, the same ciphertext will be generated after the same plaintext is encrypted) 2) CBC: ciphertext link (in common use, XOR operation needs to be performed with the previous ciphertext before plaintext encryption, that is, different ciphertexts are generated after the same plaintext encryption)

In addition to these two common working modes, there are:

3) CFB: ciphertext feedback 4) OFB: output feedback 5) CTR: counter

These five working modes are mainly applied in the derivation and calculus of algorithms in cryptography.

6. Block cipher filling method

1) Nopadding: no padding 2) pkcs5padding: 3) iso10126padding:

7. Common symmetric passwords:

1) Des (data encryption standard) 2) 3DES (Triple DES, deSede, algorithm with triple des encryption) 3) AES (Advanced Encryption Standard, AES algorithm can effectively resist the attack algorithm against DES)

Let's take a look at the simple comparison of these three algorithms:

Let's look at how to use DES / 3DES / AES algorithms to realize symmetric encryption:

2. DES algorithm

1. Des: data encryption standard, which is a typical algorithm in the field of symmetric encryption algorithm

2. Features: short key (56 bits), short life cycle (avoid being cracked)

3. Java implementation

1) Generate key

2) Encryption

3) Decryption

We can find that we only set different modes for encryption and decryption.

3.3des algorithm

1.3des: increase the key length to 112 bits or 168 bits to improve security by increasing the number of iterations

2. Disadvantages: slow processing speed, long key calculation time and low encryption efficiency

3. Java implementation

1) Generate key

2) 3DES encryption

3) 3DES decryption

4. AES algorithm (recommended)

1. AES: advanced data encryption standard, which can effectively resist all known attacks against DES algorithm

2. Features: short key establishment time, good sensitivity, low memory demand and high security

3. Java implementation

1) Generate key

2) AES encryption

3) AES decryption

For ease of use, I have compiled tool classes for DES / 3DES / AES algorithms,

Address: http://xiazai.jb51.net/201701/yuanma/Android-UtilsLibrary-master (jb51.net). Rar (New DES / 3DES / AES tool class).

So far, it's over for DES / 3DES / AES algorithms to realize symmetric encryption

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>