CryptoKey
A cryptographic key (RSA or elliptic-curve).
A cryptographic key (RSA or elliptic-curve).
The CryptoKey class represents a cryptographic key. Keys can be loaded and saved like any other Resource.
They can be used to generate a self-signed X509Certificate via Crypto.GenerateSelfSignedCertificate and as private key in StreamPeerTls.AcceptStream along with the appropriate certificate.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
CryptoKeyConstructor
public CryptoKey();Methods5
IsPublicOnlybool
public bool IsPublicOnly();Returns true if this CryptoKey only has the public part, and not the private one.
boolLoadError
public Error Load(string path, bool publicOnly = false);Loads a key from path. If public_only is true, only the public key will be loaded.
Note: path should be a ".pub" file if public_only is true, a ".key" file otherwise.
| Name | Type | Default |
|---|---|---|
path | string | — |
publicOnly | bool | false |
ErrorLoadFromStringError
public Error LoadFromString(string stringKey, bool publicOnly = false);Loads a key from the given string_key. If public_only is true, only the public key will be loaded.
| Name | Type | Default |
|---|---|---|
stringKey | string | — |
publicOnly | bool | false |
ErrorSaveError
public Error Save(string path, bool publicOnly = false);Saves a key to the given path. If public_only is true, only the public key will be saved.
Note: path should be a ".pub" file if public_only is true, a ".key" file otherwise.
| Name | Type | Default |
|---|---|---|
path | string | — |
publicOnly | bool | false |
ErrorSaveToStringstring
public string SaveToString(bool publicOnly = false);Returns a string containing the key in PEM format. If public_only is true, only the public key will be included.
| Name | Type | Default |
|---|---|---|
publicOnly | bool | false |
string