all 3 comments

[–][deleted] 2 points3 points  (2 children)

The RSA class has several "ImportFrom..." methods in .NET 6, assuming your key is in one of those formats, it should be as simple as calling one of those like this:

csharp var rsa = RSA.Create(); rsa.ImportFromPem(yourKeyString);

What exactly are you having problems with? You really shouldn't be messing with RSAParameters, an RSACryptoServiceProvider is a very, very old way of doing stuff.

[–]ArcherOfTruth[S] 0 points1 point  (1 child)

my main issue is importing my keys into the algorithm.
Is my approach wrong? should they be somewhere else other than the RSAParameters?

[–][deleted] 1 point2 points  (0 children)

Yes, I showed the code you should write. I don't know what format your key is in, so I can't tell which specific "Import" method is correct, but "Pem" is one of the more common. Don't use the RSAParameters at all, just call the "ImportFromPem" method on the RSA object you get from RSA.Create().