Show / Hide Table of Contents

Class RSAXmlPemStringConverter

Extension method class for converting string RSA keys from and to the xml/pem formats.

Inheritance
System.Object
RSAXmlPemStringConverter
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GlitchedPolygons.ExtensionMethods.RSAXmlPemStringConverter
Assembly: GlitchedPolygons.ExtensionMethods.RSAXmlPemStringConverter.dll
Syntax
public static class RSAXmlPemStringConverter

Methods

FromXmlStringNetCore(RSA, String)

Imports an xml string that was obtained using ToXmlStringNetCore(RSA, Boolean) into an System.Security.Cryptography.RSA instance.

Declaration
public static void FromXmlStringNetCore(this RSA rsa, string xmlString)
Parameters
Type Name Description
System.Security.Cryptography.RSA rsa

The System.Security.Cryptography.RSA instance to import the key into.

System.String xmlString

The xml string that contains the RSA key to import.

PemToXml(String)

Returns the specified RSA key (PEM string) converted to XML.

Declaration
public static string PemToXml(this string pem)
Parameters
Type Name Description
System.String pem

The PEM string to convert to XML.

Returns
Type Description
System.String

System.String.

Exceptions
Type Condition
Org.BouncyCastle.Security.InvalidKeyException

Unsupported PEM format

ToXmlStringNetCore(RSA, Boolean)

Converts an System.Security.Cryptography.RSA instance to a portable xml string.

Declaration
public static string ToXmlStringNetCore(this RSA rsa, bool includePrivateParameters = false)
Parameters
Type Name Description
System.Security.Cryptography.RSA rsa

The System.Security.Cryptography.RSA instance whose key params you want to export to a portable xml string.

System.Boolean includePrivateParameters

Should the private key be exported?

Returns
Type Description
System.String

The exported RSA key string in portable xml; null if export failed.

XmlToPem(String)

Returns the specified XML RSA key string converted to the PEM format.

Declaration
public static string XmlToPem(this string xml)
Parameters
Type Name Description
System.String xml

The XML string containing the RSA key.

Returns
Type Description
System.String

System.String.

Exceptions
Type Condition
Org.BouncyCastle.Security.InvalidKeyException

Invalid XML RSA Key

Back to top Generated by DocFX