CapyKit/Docs/api/CapyKit.Helpers.KeyHelper.md

4.9 KiB

Class KeyHelper

Namespace: CapyKit.Helpers
Assembly: CapyKit.dll

A class that contains methods for managing key creation and validation against a master key.

public class KeyHelper

Inheritance

objectKeyHelper

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

ObjectExtensions.UpdateProperties<KeyHelper>(KeyHelper, KeyHelper), ObjectExtensions.UpdateProperties(object, object)

Methods

GenerateKey()

Generates a random key.

public string GenerateKey()

Returns

string

The key.

GetMasterKey()

Gets the master key.

public byte[] GetMasterKey()

Returns

byte[]

An array of byte.

Exceptions

InvalidOperationException

Thrown when the requested operation is invalid.

GetNumParts()

Gets the number parts.

public int GetNumParts()

Returns

int

The number parts.

Exceptions

ArgumentException

Thrown when one or more arguments have unsupported or illegal values.

GetSaltSize()

Gets the salt size.

public int GetSaltSize()

Returns

int

The salt size.

SetMasterKeyAccessor(Func<byte[]>)

Sets the master key.

public void SetMasterKeyAccessor(Func<byte[]> accessor)

Parameters

accessor Func<byte[]>

The accessor function.

SetNumPartsAccessor(Func<int>)

Set and get the number of parts for the formatted key. Default is 2.

public void SetNumPartsAccessor(Func<int> accessor)

Parameters

accessor Func<int>

The accessor function.

SetSaltSizeAccessor(Func<int>)

Sets the salt size (in bytes). Default is 4.

public void SetSaltSizeAccessor(Func<int> accessor)

Parameters

accessor Func<int>

The accessor function.

ValidateKey(string)

Validates the provided key.

public bool ValidateKey(string providedKey)

Parameters

providedKey string

The provided key.

Returns

bool

True if it succeeds, false if it fails.

See Also

KeyHelper.GetMasterKey, KeyHelper.SetMasterKeyAccessor[Func](https://learn.microsoft.com/dotnet/api/system.func\-1)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]\>, KeyHelper.masterKeyAccessor