Class KeyHelper
A class that contains methods for managing key creation and validation against a master key.
Namespace: CapyKit.Helpers
Assembly: CapyKit.dll
Syntax
public class KeyHelper
Methods
GenerateKey()
Generates a random key.
Declaration
public string GenerateKey()
Returns
| Type | Description |
|---|---|
| string | The key. |
GetMasterKey()
Gets the master key.
Declaration
public byte[] GetMasterKey()
Returns
| Type | Description |
|---|---|
| byte[] | An array of byte. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when the requested operation is invalid. |
GetNumParts()
Gets the number parts.
Declaration
public int GetNumParts()
Returns
| Type | Description |
|---|---|
| int | The number parts. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
GetSaltSize()
Gets the salt size.
Declaration
public int GetSaltSize()
Returns
| Type | Description |
|---|---|
| int | The salt size. |
SetMasterKeyAccessor(Func<byte[]>)
Sets the master key.
Declaration
public void SetMasterKeyAccessor(Func<byte[]> accessor)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<byte[]> | accessor | The accessor function. |
SetNumPartsAccessor(Func<int>)
Set and get the number of parts for the formatted key. Default is 2.
Declaration
public void SetNumPartsAccessor(Func<int> accessor)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<int> | accessor | The accessor function. |
SetSaltSizeAccessor(Func<int>)
Sets the salt size (in bytes). Default is 4.
Declaration
public void SetSaltSizeAccessor(Func<int> accessor)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<int> | accessor | The accessor function. |
ValidateKey(string)
Validates the provided key.
Declaration
public bool ValidateKey(string providedKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | providedKey | The provided key. |
Returns
| Type | Description |
|---|---|
| bool | True if it succeeds, false if it fails. |