RSA Encryption in C#

  • I am trying to implement RSA Encryption into my program.

    Here is my code :

    using System;
    using System.Security.Cryptography;
    string dataToEncrypt = "my data here";
    string modulus= "my public key here";
    string exponent= "my public key expiry here";
    RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
    RSAParameters RSAKeyInfo = new RSAParameters();
    RSAKeyInfo.Modulus = Encoding.UTF8.GetBytes(modulus);
    RSAKeyInfo.D = Encoding.UTF8.GetBytes(dataToEncrypt);
    RSAKeyInfo.Exponent = Encoding.UTF8.GetBytes(exponent);

    I've also had a looked at Ruri's code in OpenBullet but I haven't managed to get it working.

    Anyone know how to get it working?

  • This is my error code for anyone interested:

    System.Security.Cryptography.CryptographicException: 'Bad Data.'

  • bouncy castle is a good library I suggest you use that

  • Where can I get that?

  • RSA fixed in 1.2.1

    Wait for crowfounding goal.

Log in to reply