/// <summary> /// Create RsaKey from PEM format /// </summary> /// <param name="pem">The PEM string</param> /// <param name="isPrivate">Indicates if it contains the private parameters</param> /// <returns>RsaKey</returns> public static RsaKey Create(string pem, bool isPrivate) => new RsaKey((isPrivate) ? PemHelper.ImportPrivateKey(pem) : PemHelper.ImportPublicKey(pem));
public string ToPemString(bool withPrivate) { using var csp = new RSACryptoServiceProvider(); csp.ImportParameters(Parameters); return((withPrivate) ? PemHelper.ExportPrivateKey(csp) : PemHelper.ExportPublicKey(csp)); }