Class RSAXmlPemStringConverter
Extension method class for converting string
RSA keys from and to the xml/pem formats.
Inheritance
Inherited Members
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 |
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 |
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 |
System.Boolean | includePrivateParameters | Should the private key be exported? |
Returns
Type | Description |
---|---|
System.String | The exported RSA key |
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 |
Returns
Type | Description |
---|---|
System.String | System.String. |
Exceptions
Type | Condition |
---|---|
Org.BouncyCastle.Security.InvalidKeyException | Invalid XML RSA Key |