Table of Contents

Class AccessCodeUtils

Namespace
VpnHood.Net.Toolkit.Utils
Assembly
VpnHood.Net.Toolkit.dll

Provides access codes: 20 characters, the version digit 1, a check digit, and 18 random characters.

public static class AccessCodeUtils
Inheritance
AccessCodeUtils
Inherited Members

Methods

Build(string)

Builds an access code from its random part, which it neither checks nor makes.

public static string Build(string random)

Parameters

random string

The random part, 18 ASCII letters or digits for a valid code.

Returns

string

The access code: 1, the check digit, then the random part.

Format(string?)

Formats a code for reading, with a dash after every four characters.

public static string Format(string? value)

Parameters

value string

The code, or null.

Returns

string

The formatted code, or empty.

Redact(string?)

Hides a valid access code but its last four characters, for a log or a screen.

public static string? Redact(string? accessCode)

Parameters

accessCode string

The access code, or null.

Returns

string

The code with all but its last four characters as *, or null when it is not valid.

TryValidate(string)

Checks an access code, as Validate(string) does, without throwing.

public static string? TryValidate(string accessCode)

Parameters

accessCode string

The access code, as typed.

Returns

string

The code without its separators, or null when it is not valid.

Validate(string)

Checks an access code: what is not an ASCII letter or digit, such as a dash, is dropped, and the rest must be version 1's 20 characters with a matching check digit.

public static string Validate(string accessCode)

Parameters

accessCode string

The access code, as typed.

Returns

string

The code without its separators.

Exceptions

ArgumentException

The code is empty, of another version or length, or its check digit does not match.