当前位置:网站首页>Encrypt / decrypt public / private key

Encrypt / decrypt public / private key

2022-06-10 05:40:00 Driver: Zhaosi

One : encryption / Decrypt

encryption : The process of converting plaintext into ciphertext
Decrypt : The process of converting ciphertext into plaintext

Two : Secret key

The essence of a secret key is a string , Its unit of measurement is bit( position ), According to the way the secret key is used , Encryption can be divided into two categories , Symmetric and asymmetric encryption , Symmetric encryption means that both encryption and decryption use the same secret key , At present, the most popular symmetric encryption algorithm is AES encryption algorithm , The length of the secret key is 128、192 or 256, High security , Good performance .

  • Encrypted packet mode : Encrypt plaintext groups , Used in wechat payment AEAD_AES_256_GCM Group encryption .

Asymmetric encryption means that only the private key can be used for decryption after public key encryption , In turn, , After the private key is encrypted, it can only be decrypted with the public key , among RSA Encryption algorithm is the most famous asymmetric encryption algorithm .
for instance : If Tom、Jerry To a friend zhangsan Send a message ,zhangsan You can distribute your public key to Tom and Jerry, such Tom and Jerry You can use this public key to encrypt , At this time, only those who have the private key zhangsan Can decrypt the message , Ensure the confidentiality of the message . Conversely, suppose zhangsan Encrypt with the private key ,Tom And Jerry After receiving the message, use zhangsan Decrypt the distributed public key , Successful decryption indicates that the message is zhangsan Sent .

3、 ... and : Symmetric encryption VS Asymmetric encryption

Symmetric encryption :
advantage ; It's fast
shortcoming : The secret key needs to be shared by both sides of the information exchange , Once stolen , The message will be cracked

Asymmetric encryption :
advantage : Private key is strictly confidential , Public key arbitrary distribution , Hackers can't crack the ciphertext after obtaining the public key
shortcoming : It's very slow

Four :HTTPS Encrypted transmission process

 Insert picture description here
stay HTTPS In transit , Both transmission speed and transmission security shall be ensured , At this time, the server public key can be transmitted asymmetrically , After the server obtains the encrypted session master secret key , Then decrypt the server private key to obtain the session master key , Then use symmetric encryption for data transmission to ensure transmission efficiency .

原网站

版权声明
本文为[Driver: Zhaosi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091010361521.html