Class AccessCodeUtils
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
randomstringThe 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
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
Returns
TryValidate(string)
Checks an access code, as Validate(string) does, without throwing.
public static string? TryValidate(string accessCode)
Parameters
accessCodestringThe access code, as typed.
Returns
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
accessCodestringThe 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.