I have a 2048 bits public key (asymmetric, RSA) of which I know the Modulus and Exponent and need to encrypt a string.
Ideally, I want to encrypt a small string in c# and later on decrypt it with python.
I have a 2048 bits public key (asymmetric, RSA) of which I know the Modulus and Exponent and need to encrypt a string.
Ideally, I want to encrypt a small string in c# and later on decrypt it with python.
You will have to carefully check all standards involved, these encryptions should be cross-platform but it's vulnerable. It helps if you have a setup where you can inspect all the various byte-arrays, you don't want to be chasing an error that comes from an ASCII/UTF8 encoding difference.
Your title mentions a 'file', note that RSA only encrypts data up to the key size. It is usually used to encrypt (MD5/SHA1) hashes or keys for other encryptions. The RSA classes have extended support for signing and verifying signatures.
You will find the most relevant steps here (MSDN). Note that you will have to import the keys whereas the example exports them.