1

When I drill down into the .Net source code I cannot find the code that actually runs when rsa.Encrypt is called, maybe it's running code within a DLL because I cannot find where the method is overridden

Please can you point me to the source code of the function rsa.Encrypt or explain what it is doing here to encrypt a byte array (keeping each value 0>255)

I've tried drilling down into the .net source code

https://referencesource.microsoft.com/#mscorlib/system/security/cryptography/rsa.cs

I have tried to step into the code to debug it (it just skips over without stepping into)

I've tried to understand how RSA can encrypt numbers whilst keeping them within an integer ring (i.e 0>255)

    public byte[] Encrypt(string publicKeyXML, string dataToEncript)
    {
        RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
        rsa.FromXmlString(publicKeyXML);
        return rsa.Encrypt(ASCIIEncoding.ASCII.GetBytes(dataToEncript), true);
    }
1
  • Depends on the CSP used. By default a native method is used that uses the key stores of the system. Don't use true or false for the padding method, they have changed that call for a reason. Feb 4 '20 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.