Click or drag to resize

RsaReadPrivateKey Method

Read from a file or string containing a private key into an "internal" private key string.

Namespace: CryptoSysPKI
Assembly: diCrSysPKINet (in diCrSysPKINet.dll) Version: 23.0.0.25611 (23.0.0.0)
Syntax
public static StringBuilder ReadPrivateKey(
	string privateKeyFile,
	string password = ""
)

Parameters

privateKeyFile  String
Name of private key file or a PEM String containing the key
password  String  (Optional)
Password for private key, if encrypted

Return Value

StringBuilder
StringBuilder containing an internal representation of the private key; or an empty StringBuilder if error
Remarks
This returns a StringBuilder, not a string, to allow secure wiping. Use sb.ToString() to obtain a string.
Example
C#
StringBuilder sbPrivateKey = Rsa.ReadPrivateKey("AlicePrivRSASign.p8e", "password");
Debug.Assert(sbPrivateKey.Length > 0, "Rsa.ReadPrivateKey Failed");
Console.WriteLine("Key length={0} bits", Rsa.KeyBits(sbPrivateKey.ToString()));
See Also