Table of Contents

Class ModHex

Namespace
Yubico.Core.Buffers
Assembly
Yubico.Core.dll

Class for encoding and decoding byte collections into MODHEX.

public class ModHex : Base16, ITextEncoding
Inheritance
object
ModHex
Implements
Inherited Members

Properties

CharacterSet

The set of characters that correspond to numbers 0 - 16.

protected override Span<char> CharacterSet { get; }

Property Value

Span<char>

DefaultLowerCase

Indicates the default case of characters for this encoding.

protected override bool DefaultLowerCase { get; }

Property Value

bool

Remarks

This is used when decoding data to check for characters that are in an unexpected case. To match nibbles (4-bit values) to a character, we must change the case of the character to match what's expected. For example, the reference string for ModHex is cbdefghijklnrtuv. If we receive a 16-bit value in ModHex that looks like CCCB, then the matching algorithm needs to know to change each character as it is being evaluated to cccb.

Methods

DecodeText(ReadOnlySpan<char>, Span<byte>)

public static void DecodeText(ReadOnlySpan<char> encoded, Span<byte> data)

Parameters

encoded ReadOnlySpan<char>
data Span<byte>

DecodeText(string)

public static byte[] DecodeText(string encoded)

Parameters

encoded string

Returns

byte[]

EncodeBytes(ReadOnlySpan<byte>)

public static string EncodeBytes(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

Returns

string

EncodeBytes(ReadOnlySpan<byte>, Span<char>)

public static void EncodeBytes(ReadOnlySpan<byte> data, Span<char> encoded)

Parameters

data ReadOnlySpan<byte>
encoded Span<char>