Symmetric Encryption and Asymmetric Encryption

In digital encryption algorithms, they can be divided into symmetric encryption and asymmetric encryption.

Symmetric Encryption

In symmetric encryption algorithms, the same key is used for both encrypting and decrypting data, that is, the same password is used to encrypt and decrypt the content.

Content + Key = Ciphertext Ciphertext - Key = Original content

Advantages

Fast encryption and decryption, high efficiency, suitable for one-to-one information encryption and transmission.

Disadvantages

Before data transmission, the key must be negotiated. If either party's key is leaked, the encrypted information becomes insecure. It is not suitable for one-to-many situations. If multiple people share the same key, it increases the risk of key leakage and cannot provide non-repudiation. If each pair of people uses a unique key, it will lead to the management difficulty of having too many keys.

Common Algorithms

  • DES (Data Encryption Standard): It is a block cipher algorithm that encrypts and decrypts data in 64-bit blocks.
  • 3DES: The principle is almost the same as DES, but it uses 3 keys to encrypt the same data three times, enhancing the encryption strength.
  • AES (Advanced Encryption Standard): This algorithm can effectively resist attacks against DES.
  • Additionally, there are algorithms such as Blowfish, IDEA, RC4, RC5, RC6, etc.

Asymmetric Encryption

Asymmetric encryption algorithms require two keys: public key and private key. The private key cannot be known by anyone else, while the public key can be freely disclosed. They can encrypt and decrypt data with each other: the public key encrypts data, and only the corresponding private key can decrypt it; the private key encrypts data, and only the corresponding public key can decrypt it. Public key encrypts, private key decrypts; private key signs, public key verifies.
For the content encrypted with the public key, only the private key can unlock it. As long as my private key is not leaked, the data transmission is secure, even if others intercept the ciphertext, they cannot decrypt its content.
For the content encrypted with the private key, similarly, only the public key can decrypt it. But the public key has already been distributed, and anyone can decrypt the private key content. Its application scenario is to verify digital signatures, i.e., to verify whether the message was sent by me rather than someone else. I will hash the content I am going to send, then encrypt the digest information of the hash using my private key as a digital signature. When the recipient decrypts my digital signature with the public key and then uses the same hash algorithm to hash the content to verify that it was sent by me and the data has not been tampered with.

Advantages

Higher security, with absolute advantages in protecting communication security.

Disadvantages

The encryption and decryption speed is much slower than symmetric encryption. The encryption algorithm is extremely complex, and the security depends on the algorithm and the key.

Common Algorithms

  • RSA: It is currently the most influential and commonly used asymmetric encryption algorithm, and it can resist the vast majority of known cryptographic attacks and has been endorsed by ISO as the public key data encryption standard.
  • Additionally, there are algorithms such as ECC, Diffie-Hellman, El Gamal, DSA, etc.

HASH Algorithm

The HASH algorithm is a message digest algorithm, not an encryption algorithm, but because of its one-way operation and irreversibility, it has become a part of encryption algorithms. A complete encryption mechanism cannot rely solely on the HASH algorithm. HASH, also known as a hash function, a strong HASH function must be irreversible, which means that no original information can be deduced from the HASH result. Any change in the input information, even if only one bit, will lead to a significant change in the HASH result, known as the avalanche effect. The HASH should also be collision-resistant, meaning that two pieces of information with the same HASH result cannot be found. HASH results with these characteristics can be used to verify whether the information has been modified.

Common Algorithms

MD5, SHA, MAC, CRC, SM3.

Daily Question

https://github.com/WindrunnerMax/EveryDay

Reference

http://www.ruanyifeng.com/blog/2011/08/what_is_a_digital_signature.html