Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 365129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:30:28+00:00 2026-05-12T13:30:28+00:00

My server creates a RSACryptoServiceProvider and exports its parameters to a variable (RSAKeyInfo). Then,

  • 0

My server creates a RSACryptoServiceProvider and exports its parameters to a variable (RSAKeyInfo).

Then, the public key is sent to the client, and the client encrypts something with that public key.

Now, I need to be able to decrypt this very data when sent back to the server – hence why RSA is useful in my case.

However, I get a “Bad Data” exception when trying to recreate a RSACryptoServiceProvider with imported parameters from the first RSACryptoServiceProvider created previously.

… Code might be clearer.

Creating the crypto:

class Cryptograph
{
    public Cryptograph()
    {
        this.RSAKeyInfo = new RSACryptoServiceProvider(2048, new CspParameters(1)).ExportParameters(true);
    }
}

Accessing it later for decryption:

byte[] encrypted = ...;

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.ImportParameters(this.Cryptograph.RSAKeyInfo);

byte[] decrypted = rsa.Decrypt(encrypted, false);
Console.WriteLine(Utilities.ByteArrayToHexString(decrypted));

I get the “Bad Data” exception at this line:

byte[] decrypted = rsa.Decrypt(encrypted, false);

What am I doing wrong? How can I do it properly?
Thank you 🙂

P.S.: Please don’t send MSDN or obvious Google results links, I’ve read all these pages and still can’t get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:30:28+00:00Added an answer on May 12, 2026 at 1:30 pm

    I needed an encryption/decryption that used no padding, and C#.NET doesn’t provide it by default. OpenSSL.NET will do the job, however, I’m stuck while trying to use it. (See this question if you want to help me make it work). 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send RSA public key from C# server to iPhone, so I
Server creates new thread in a threadpool. This thread reads some stuff into buffer
We all know that WebLogic server creates logs directory under DOMAIN_HOME/servers/SERVER_NAME directory at server
I'm writing http session manager (gen_server based). That server creates and removes session from
I'm working on a simple ftp server in c. I don't know when ftp
I'm new to the .NET CryptoProvider space, and am a little concerned by what
I have this function I am using to decrypt values that works fine on
This is another question in the line of getting C# and PHP to exchange
I don't know if i am asking a silly question but I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.