Basic cryptography knowledge
I recently liked the CSDN forum and encountered many questions about cryptography. I found that many people do not have enough basic knowledge about cryptography, which may cause some misunderstandings or even jokes. For example, MD5 encryption, MD5 decryption, and so on. I think that since everyone is engaged in software or programming, they should also have some computer knowledge. These basic knowledge should still be understood. It should also be easier to understand, so let's talk about it easily.
1. Role and basic concepts of cryptography.
First, it is explained that cryptography and encryption and decryption are not the same thing: cryptography covers a wide range and is a major discipline, including the password protocol, password algorithm, hash algorithm, digital signature, digital watermark, and password analysis. Encryption and decryption in our program is only one aspect of it.
There is no need to talk about the basic concepts and models. What cryptography studies: Simply put, it is about how to securely and effectively transmit information between a sender and a receiver. The following describes several frequently used concepts.
2. Several Basic Concepts
Data Encryption is the most commonly used one. It uses an encryption algorithm and a specific key to protect important sensitive information and decrypt it as needed. Encryption algorithms can be divided into two types:
1) symmetric encryption algorithm. This is what we usually call DES, RC2, AES, and so on. These are widely used internationally, but they are actually international standards. The encryption key and decryption key are the same. The length of the key can be different according to different algorithms, generally 128,192,256 bits. Symmetric encryption is fast, but key distribution is a difficult issue (this issue does not need to be considered for small applications ). Generally, a large amount of data is encrypted using symmetric encryption algorithms .. NET has four default symmetric encryption algorithms. You can use it directly.
2) asymmetric encryption algorithm, also known as the public key password. For example, I usually call RSA. The special feature of a public key is that its encryption key and decryption key are different. Generally, This is a magical thing. This feature has brought about an excellent solution to key distribution difficulties. For example, encrypt the plaintext with a symmetric password, and encrypt the key with an asymmetric password, and then transmit the ciphertext to the receiver, you can use your own private key to decrypt the ciphertext encrypted by the asymmetric password. This gives you a symmetric encryption key that is then used to decrypt the plaintext. Asymmetric passwords are rarely used in general applications, and their encryption and decryption speed is slow. They are only suitable for encrypting a small amount of important data. Its key is very long. It may be about-bits, depending on the large prime number used.
3) hash function. That is, the common hash function is MD5 and SHA. A hash function is equivalent to a "fingerprint". It is irreversible and has no key. Given any length message M, a fixed length hash value m can be generated. Hash functions must meet the following requirements: Calculate M's hash value quickly; otherwise, it is quite difficult, and it is difficult to find two messages with the same hash value. It is generally used to prevent tampering. For example, when many large software downloads, the file hash value will be published on the website. After downloading, you can calculate the hash value comparison based on the tool, check whether the file is correct or modified. Hash is not equivalent to encryption. In many cases, developers hash and save the passwords in the User table. In fact, it is not called encryption, but it is equivalent to saving the "feature fingerprint" of the password, for illegal attackers, it is extremely difficult to obtain a password with the same fingerprint without knowing the real "password.
Publish via Wiz