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

  • Home
  • SEARCH
  • 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 6883285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:21:47+00:00 2026-05-27T05:21:47+00:00

Until today I was living under the impression that RSA encryption using RSA is

  • 0

Until today I was living under the impression that RSA encryption using RSA is deterministic. After all, how should signature verification work if it wasn’t?

To my big suprise, .NETs RSACryptoServiceProvider does not have a stable output when encrypting the same set of bytes with the same keys:

[Fact]
public void Learning()
{
    const int keySize = 1024;

    System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider(keySize);

    var bytes = GenerateRandomDataWithLength( 36 );

    for (int i = 0; i < 4; i++)
        Assert.Equal( rsa.Encrypt( bytes, false ), rsa.Encrypt( bytes, false ) );
}

byte[] GenerateRandomDataWithLength( int length )
{
    Random r = new Random();

    byte[] data = new byte[length];
    r.NextBytes( data );

    return data;
}

I have skimmed through the PKCS Specification and I do understand the math behind RSA, so I really wonder why I am observing the output to be unstable.

Mono’s RSA implementation has a stable output. The unstable output of Encrypt does not affect decryption, which is well possible and yields the expected data.

  • 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-27T05:21:48+00:00Added an answer on May 27, 2026 at 5:21 am

    RSA encryption is pure mathematic so it will give you the same result everytime. However calling Encrypt in .NET is not simply doing RSA encryption.

    Why ? The PKCS#1 padding (default when you use false in Encrypt) will make every encrypted result different because it includes random data (for padding purpose).

    Mono has the same behavior (at least on my system, see note). However if you are using EncryptValue, which Mono supports but .NET does not (CryptoAPI limitation), then no padding will be done and the encrypted result will be identical each time.

    Note: If you have different results please fill a bug report on http://bugzilla.xamarin.com and include the version number you are using.

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

Sidebar

Related Questions

Up until today, all AS3 based game engine (flixel, pushbutton and etc) that I
Until yesterday everything was normal but today i try to lauch my application using
Somehow I never noticed until today that C++ supports nested classes. This surprised me
Have a have a Windows VPS using Plesk 9. Until today I have been
I've been using Javascript's Date for a project, but noticed today that my code
Until today, my understanding of .NET Tuple classes had been that they delegate their
I didn't notice it until today during some testing locally on my pc, that
Once again, I'm questioning a longstanding belief. Until today, I believed that the alignment
Until today, I thought that for example: i += j; Was just a shortcut
Up until today, I had always thought that decent compilers automatically convert struct pass-by-value

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.