Show / Hide Table of Contents

UseKey Method

UseKey(ReadOnlyMemory<byte>)

Explicitly sets the key of the credential.

C#
public ConfigureHotp UseKey(ReadOnlyMemory<byte> key)

Parameters

Type Name Description
ReadOnlyMemory<byte> key

A collection of bytes to use for the key.

Returns

ConfigureHotp

The current ConfigureHotp instance.

Exceptions

Type Condition
InvalidOperationException

This is thrown when GenerateKey(Memory<byte>) has been called before this.

ArgumentException

This is thrown when key is not the correct length.

Remarks

The System.Memory<T> collection containing the key is used by the operation to program the YubiKey, but the source continues to be owned by the caller. This means that the caller is responsible for clearing the memory after use to avoid exposing sensitive information.

Setting an explicit key is not compatible with generating a key. Specifying both will result in an exception.

In this article
Back to top Generated by DocFX