public static System.Security.Cryptography.RSA RsaFromString(string rsaKey) { Check.Argument.IsNotEmpty(rsaKey, nameof(rsaKey)); System.Security.Cryptography.RSA rsa = System.Security.Cryptography.RSA.Create(); rsa.FromJsonString(rsaKey); return rsa; }
public static (string publicPem, string privatePem) RSAToPem(bool isPKCS8) { var rsaKey = RsaKey.CreateRsaKey(); using (System.Security.Cryptography.RSA rsa = System.Security.Cryptography.RSA.Create()) { rsa.FromJsonString(rsaKey.PrivateKey); var publicPem = RsaProvider.ToPem(rsa, false, isPKCS8); var privatePem = RsaProvider.ToPem(rsa, true, isPKCS8); return(publicPem, privatePem); } }