.NET Public Private Key Based Encryption

2019-08-09 23:15发布

问题:

I need to encrypt some info using my Public/Private key, and allow the other party(users) to ONLY DECRYPT what I encrypted. I don't want them to be able to know how I encrypted my message. How it is possible in .NET using public and private key pair?

I tried RSACryptoServiceProvider in .NET but the issue with that is

i) We can only encrypt using Public key and decrypt using Private key ii) Private key xml string always contains public key xml string.

So if i use RSA than i have to distribute Private key along with public key to the users who needs to decrypt my message.

Can you please help how to over come above situation where i do not have to send enrypting key information along with decryption key

Please help

Thanks

回答1:

You are right using the RSACryptoServiceProvider for this, but I don’t understand your problem.

If you use the RSACryptoServiceProvider you do a server-side encryption with the complete key (public and private) and a client-side decryption with only the public part of the key. So you have to publish only the public part of the key. That is what you want and that's the way it works.

On the other hand: The way you describe it in your question, wouldn’t work. You can’t encrypt with just the public key! There is something wrong in your question and/or your code.



回答2:

Looks like you want to sign your data and not encrypt it.