Score:-2

Encrypt private key and decrypt with the public key

fr flag

Is it possible to encrypt with the RSA private key and decrypt with the RSA public key(not for signature) The task is that I have to encrypt the data with a private key. Transfer this data to another person and he decrypted it with a public key, added the data and encrypted it with the same public key and sent it to me. The whole task is written in Python, can there be any libraries for this?

A. Hersean avatar
cr flag
I suggest you ask for a solution to the problem you are trying to solve, including why you want to encrypt with a private key, on https://security.stackexchange.com/ People there might be able to help you design a proper solution to your problem.
Felix avatar
fr flag
Thank you very much for your help
fgrieu avatar
ng flag
It's never sound to decrypt with a public key, because (by definition of public) anyone can decrypt, and that goes against the purpose of encryption. High-level libraries with a well-thought interface therefore won't let you do it. Whatever reason you are trying to do it, it's wrong. Possibly, it's asked to perform signature with the private key, and signature verification using the public key, using a terminology that's vetted wrong by the cryptographic community for the last 30 years (libraries for signature will be happy to do it). Another (unsafe) option is to (mis)use `pow` directly.
A. Hersean avatar
cr flag
For information: the OP asked the same question on https://security.stackexchange.com/q/255065/127837 but without describing the underlying issue to solve. So it was closed.
Score:3
cr flag

The public key is public. You should consider that anybody can have a copy of it, including an attacker. By encrypting with a private key, anybody could decrypt the data with the public key, defeating the point of encrypting in the first place.

DO NOT DO IT.

Felix avatar
fr flag
Thank you for your attention, but in this project, this is exactly how the encryption technique is needed.
SAI Peregrinus avatar
si flag
It's impossible. If anyone can decrypt it, it's not encryption, by definition. You cannot encrypt anything with a private key. It's like asking how you can hide something by putting it in a clear glass box in the middle of Times Square.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.