How can I decrypt with public key. RRS feed

  • Question

  • Basically I have set up RSAServiceProvider with public key only. And I want to decrypt data with it. How can I do this.
    Saturday, March 24, 2018 5:52 AM

All replies

  • I'm not familiar with security but I think you can not decrypt data by public key. Public key is used to encrypt data which could be decrypted by private key only. See as asymmetric system works.
    Saturday, March 24, 2018 6:05 AM
  • The RSACryptoServiceProvider provides an asymmetric cryptography algorithm. The characteristic of this type of algorithm is that whatever you encrypt with the private key can be decrypted with the public key, and vice-versa. This means if some data was encrypted with a given private key, and the public key that you have is the one that corresponds to the encrypting private key, then you can decrypt the data.

    The MSDN documentation for the RSACryptoServiceProvider contains an example for encryption and decryption at the bottom of the page:

    If you have the already-encrypted data, you can decrypt it by using only half of the example (the one that decrypts). But this will only work if you have the public key that is paired with the private key that was used wherever the data was encrypted in the first place.

    Saturday, March 24, 2018 11:02 AM