Read from a file or string containing a public key into an "internal" public key string.
Namespace: CryptoSysPKIAssembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntaxpublic static StringBuilder ReadPublicKey(
string certOrPublicKeyFile
)
Public Shared Function ReadPublicKey (
certOrPublicKeyFile As String
) As StringBuilder
Parameters
- certOrPublicKeyFile String
- Name of X.509 certificate or public key file or a PEM String containing the key
Return Value
StringBuilderStringBuilder containing an internal representation of the
public key; or an empty StringBuilder if error
RemarksThis returns a StringBuilder, not a string.
Use sb.ToString() to obtain a string.
Example
string pubkeyFile = "AlicePubRSA.pub";
StringBuilder sbPublicKey = Rsa.ReadPublicKey(pubkeyFile);
Debug.Assert(sbPublicKey.Length > 0, "Rsa.ReadPublicKey Failed");
int n = Rsa.SavePublicKey("AlicePubRSA_new", sbPublicKey.ToString(), Rsa.Format.SSL);
Console.WriteLine("Rsa.SavePublicKey returns {0} (expecting 0)", n);
See Also