What are RSA public and private keys?
Firstly, RSA is an asymmetric encryption algorithm designed by three mathematicians (Rivest, Shamir and Adleman). Asymmetric encryption is relative to symmetric encryption. Symmetric encryption algorithm means that encryption and decryption use the same key, while asymmetric encryption uses two keys (public key and private key) to encrypt and decrypt, which shows that asymmetric encryption is safer.
As the name implies, a public key is a public key that will be distributed to multiple holders, while a private key is a private password that often has only one holder.
Public key and private key characteristics
Both public and private keys can be used for encryption and decryption.
Both public key and private key can be used for encryption and decryption, and data encrypted with public key can only be decrypted with corresponding private key, and vice versa. Although both can be used for encryption, different scenarios use different keys for encryption. The rules are as follows:
1. The private key is used for signature and the public key is used for signature verification.
Signature is different from encryption. Signing is not to keep secret, but to ensure that this signature is signed by a specific person and not forged by others. Therefore, the privacy of the private key is suitable for signature purposes.
After the private key is signed, it can only be decrypted with the corresponding public key, which is public (many people can hold it), so these people use the public key to decrypt it. After the decryption is successful, they can judge that the signature is made by the person who holds the private key, and verify the legitimacy of the identity.
2. The public key is used for encryption and the private key is used for decryption, which can play the role of encryption.
Because the public key is public, many people can hold it. If it is encrypted with a private key, then everyone who holds the public key can decrypt it, which is not safe!
If you use the public key to encrypt, you can only decrypt it with the private key, which is private and not public, and can only be decrypted by a specific private key holder to ensure the security of the data.