I am trying to use this code to generate a public and private key, I am using .NET Core 2 on Windows 10
So far I had no success in running this code, it compiles just fine but when I get to the rsa.ToXmlString line it drops with a PlatformNotSupportedException and as I read in another answer on stack overflow the solution was using System.Security.Cryptography.Algorithms
and they showed the almost exact code that I use here down below.
using (RSA rsa = RSA.Create())
{
rsa.KeySize = 1024;
privateKey = rsa.ToXmlString(true);
publicKey = rsa.ToXmlString(false);
}
Error:
As seen here it does show up in their API browser, so it has to be supported, right?
Does anyone have any similar problems? Or does anyone have a fix for this?
I have to use .NET Core so don't suggest using .NET 4.6
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…