Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Public key encryption vs private key encryption

I have implemented asymmetric encryption in my project using "public key" to "encrypt" the message and "private key" to "decrypt" the message.

Do we ever use "private key" to "encrypt" the message and and "public key" to "decrypt". If yes, can someone give me a use case of that and is this kind of cryptography also called "asymmetric encryption"

like image 659
Himalay Majumdar Avatar asked Dec 14 '25 05:12

Himalay Majumdar


2 Answers

As far as the term encryption is considered to be on the message itself, the answer is no because such an encryption is totally useless. Since the public key is supposed to be public everyone could use it to decrypt. Encrypting with the private key thus fails to provide confidentiality.

Signing on the other side, as others have already mentioned is the only use case for this. It does not apply the encryption to the actual payload (the message). It encrypts a cryptographic hash over the message (that can be reproduced from the same message only), using a different padding scheme. In this way you can be sure the actual party that has the private key signed the message.

like image 103
gregdim Avatar answered Dec 16 '25 22:12

gregdim


Asymmetric means you cannot use the same key for decryption that you used for encryption. Code signing is one scenario where you encrypt using the private key. Recipients of the code can then use their public key to verify if the code was unchanged.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!