/// <summary> /// Export RSA private key /// </summary> /// <param name="rsa"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public static byte[] ExportPkcs8PrivateKey(this RSA rsa) { if (rsa is null) { throw new ArgumentNullException(nameof(rsa)); } return(Convert.FromBase64String(rsa.ToPkcs8PrivateString())); }