Class SlotAccessCode
Container for a YubiKey OTP Slot access code.
public class SlotAccessCode
- Inheritance
-
objectSlotAccessCode
Remarks
Access codes must be exactly six bytes when used in the YubiKey protocol. This helper-class assures that the access code does not exceed the maximum length, and pads the code with zeros (0x00) if less than six bytes are specified.
This class has an explicit operator that allows you to cast a byte array as a SlotAccessCode if that is more convenient than constructing one.
Constructors
SlotAccessCode()
Constructs a SlotAccessCode instance with an empty (all zeros) code.
public SlotAccessCode()
SlotAccessCode(ReadOnlyMemory<byte>)
Constructs a SlotAccessCode instance using the bytes in the collection.
public SlotAccessCode(ReadOnlyMemory<byte> bytes)
Parameters
bytes
ReadOnlyMemory<byte>The bytes to use to construct the SlotAccessCode.
Exceptions
- ArgumentException
Thrown if the length exceeds MaxAccessCodeLength
Fields
MaxAccessCodeLength
Constant giving a reference to the maximum length of an access code.
public const int MaxAccessCodeLength = 6
Field Value
- int
Operators
explicit operator SlotAccessCode(byte[])
Explicit operator to allow a byte array to be used as a parameter for methods expecting a SlotAccessCode instance.
public static explicit operator SlotAccessCode(byte[] bytes)
Parameters
bytes
byte[]The bytes to use to construct the SlotAccessCode.
Returns
Exceptions
- ArgumentException
Thrown if the length exceeds MaxAccessCodeLength