I have a program written in C# that receives a public RSA key, that is used to encrypt some data.
The key looks something like:
"-----BEGIN PUBLIC KEY-----\nMI..........QAB\n-----END PUBLIC KEY-----"
I need in my program to somehow use this key to encrypt some data. I have tried to look for a good method in the internet, but found only solutions that were either complicated (for example somehow extracting numbers from the Rsa-key string that are used as components in the key), or answers that relied on some third-party libraries, such as "Bouncy Castle".
Also, because I managed to successfully use a public key with some library in python. I have tried using a subrocess written in python that will recieve the key, some data and return the encrypted data.
That will probably work well, but is there a simpler solution using some built-in libraries in C#, such as "System.Security.Cryptography", that can import a public rsa key and use it?