Security is the key to many applications. The provision of authentication and authorization services is only part of the entire security system. What if data is used and transmitted in the application system? This is why cryptography comes from. Cryptography itself is a big topic. In the followingArticle. NET Framework and Its cryptographic classes.
Why should we use an encryption system?
Most application systems provide security features, such as logon boxes and role-based authentication. However, what if some people intercept data in the network? Or someone spoofs data transmitted online? If someone opens the database that stores the password? The password system provides a solution to the problem. With the. NET Framework Encryption Class, You can encrypt the data flowing in your system. When authenticated users need to read or modify the data, they can decrypt the data. In short, the password system has the following features:
. Protect data from being read by third parties
. Protect data from being modified by others
. Ensure that the data is accurate to the destination
Password type:
Available encryption types in. Net framwork include the following:
. Key Encryption
. Public key encryption
. Digital Signature
. Hash Encryption
All encryption-related classes can be found in the system. Security. cryptography namespace.
= Key encryption =
In key encryption, data is encrypted by a unique key. This key is only known to the recipient and sender of the information. The sender uses key encryption, and the receiver uses the same key for decryption.
. NET Framework provides the following classes for key encryption.
Descryptoserviceprovider
Rc2cryptoserviceprovider
Rijndaelmanaged
Tripledescryptoserviceprovider
: Public key encryption:
Unlike key encryption, public key encryption uses two keys. A public key and a private key. The Public Key is made public, and the private key is stored by the owner of the key. Data encrypted by a key can only be decrypted by the corresponding public key. Similarly, data encrypted by the Public Key can only be unlocked by the corresponding private key.
Naturally, to encrypt the data you want to transmit, you need to use a public key. However, it can only be unlocked by the corresponding private key.
. NET Framework provides the following classes for public key encryption.
Dsacryptoserviceprovider
Rsacryptoserviceprovider
= Digital Signature =
Digital signatures are used to confirm the sender's identity and ensure data integrity. It is often used with public key encryption. The digital signature function is as follows:
. Sender uses hashAlgorithmGenerates an abstract of the data to be sent. This abstract briefly describes the data to be sent.
. The sender uses the private key to encrypt the information digest to obtain a digital signature.
. The sender sends data through secure channels.
. The recipient receives the data and decrypts the digital signature using the public key to obtain the information digest again.
. The receiver uses the same hash algorithm to create a new information digest.
. If the sender's Information summary is consistent with the information Summary, it indicates that the information comes from the correct place.
The dsacryptoserviceprovider and rsacryptoserviceprovider classes are used to create digital signatures.
Hash encryption =
The hash algorithm creates a fixed-length output for data with a given variable length. If the source data changes, different hash values are generated. It is often used with a digital signature.
. NET provides the following hash classes.
Sha1managed
Md5cryptoserviceprovider
Mactripledes
Random number generator
In the password system, you may need to generate a key multiple times. the random number generator can meet the requirements. In. net, rngcryptoserviceprovider generates such a random number.
The next article will introduce the use of several key encryption classes