Home > Article > Operation and Maintenance > What are the encryption methods commonly used in network security?
The following are several encryption methods commonly used in network transmission:
(Learning video sharing: Programming video)
Tip: These encryptions involve plain text transmission and need to be encrypted and transmitted over the https protocol.
1. Key hashing
Use MD5 or SHA1 and other hashing algorithms to encrypt the plain text (the encryption here is only for people, not machines, because these algorithms and machines can use corresponding algorithms Calculate it)
Advantages: Anti-tampering
Applicable scenarios: Ordinary file downloads
Disadvantages: No security, certifiable
2. Symmetric encryption
Advantages: safe and authenticable
Applicable scenarios: fixed number of senders and receivers, few key users
Disadvantages: BS network transmission relationship , too many keys are difficult to maintain unless the key is encrypted and transmitted
3. Asymmetric encryption
3.1. The receiver sends the public key (to ensure data integrity)
Premise: The sender receives the receiver's public key during the first communication and saves it locally
3.2. The sender sends the public key (guaranteeing the sender's authentication)
Premise: The receiver receives the sender’s public key during the first communication and saves it locally
4, digital signature
Applicable scenarios: login authentication
Disadvantages: insufficient confidentiality
Shorthand
Symmetric Algorithm
Symmestric Algorithm.Create ()=>
Provider.CreateEncryptor()
Provider.CreateDecryptor()
CryptoStream(Stream stream,ICrytoTransform transform,CryptoStreamMode mode):
CryptoStream(encryptedSteam,encryptor,CryptoStreamMode.Write)/ /Encryption is ready to read empty encryptedSteam is ready to be written
CryptoStream(encryptedSteam,decryptor,CryptoStreamMode.Read)//Decryption is ready to be written into the ciphertext stream encryptedSteam is ready to be read
Asymmetric encryption
Asymmetric encryption (ASymmisticAlgorithm):
Provider provider
provider.ToXmlString(true);//Get the public and private key pair
provider.ToXmlString(false);//Get the public key
provier .FromXmlString(publicKeyXml);
provier.FromXmlString(privateKeyXml);
provider.Encrypt();
provider.Decrypt();
Example:
Symmetric encryption :
string key = "abc"; string sendContent="你好!"; var byteKey = Encoding.UTF8.GetBytes(key); var byteIV = Encoding.UTF8.GetBytes(key);//加密算法初始化向量 DESCryptoServiceProvider des = new DESCryptoServiceProvider();//使用des加密 byte[] bytesContent = Encoding.UTF8.GetBytes(sendContent); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byteKey, byteIV), CryptoStreamMode.Write); cs.Write(bytesContent, 0, bytesContent.Length); cs.FlushFinalBlock();
Related recommendations: Website Security Tutorial
The above is the detailed content of What are the encryption methods commonly used in network security?. For more information, please follow other related articles on the PHP Chinese website!