Class PasswordMatcher
Base class for password matchers, which test whether the characters at the current position of a password follow a particular pattern.
Inheritance
Namespace: Singulink.Cryptography
Assembly: Singulink.Cryptography.PasswordMatcher.dll
Syntax
public abstract class PasswordMatcher
Remarks
Matchers are composed into a grammar with Sequence(IEnumerable<PasswordMatcher>), Any(IEnumerable<PasswordMatcher>), Optional(PasswordMatcher), Repeat(PasswordMatcher, int, int) and Permutations(IEnumerable<PasswordMatcher>, bool). A password matches when the grammar consumes it entirely.
Custom matchers that consume text should derive from ValueMatcher. Custom matchers that compose other matchers can derive from this class directly and call GetMatches(PasswordMatchContext) on their child matchers.
The results a matcher produces for a context must depend only on the remaining characters of the password, not on the matches that preceded it, because results are cached per matcher and position for the duration of a password check. Matchers are immutable and safe to share between threads.
Methods
| Name | Description |
|---|---|
| Any(IEnumerable<PasswordMatcher>) | Creates a matcher that matches any one of the given matchers. |
| AnyChars(int, int, Func<char, bool>?, bool) | Creates a matcher that matches a short run of arbitrary characters, optionally limited to characters that pass a filter. |
| CharSequence(CharSequenceTypes, bool) | Creates a matcher that matches sequences of characters that are adjacent on a keyboard or keypad or consecutive in the alphabet, such as "qwerty", "zaq1", "!@#$", "1q2w3e4r", "7410" or "abcdef". |
| FixedDigits(int, PasswordMatchType, bool, bool) | Creates a matcher that matches a fixed number of digits. |
| FixedDigits(int, int, int, PasswordMatchType, bool, bool) | Creates a matcher that matches a fixed number of digits whose value falls within a range. |
| GetFirstMatch(string, IEnumerable<PasswordMatcher>) | Gets the first match for a password from the given matchers, or null if the password does not match any of them. |
| GetMatches(PasswordMatchContext) | Gets the contexts that result from matching this matcher at the current position of the given context. |
| GetMatchesCore(PasswordMatchContext) | Gets the contexts that result from matching this matcher at the current position of the given context, in the order they should be tried. |
| Optional(PasswordMatcher) | Creates a matcher that matches the given matcher or nothing at all. |
| Permutations(IEnumerable<PasswordMatcher>, bool) | Creates a matcher that matches the given matchers in any order, with each matcher used at most once. |
| Repeat(PasswordMatcher, int, int) | Creates a matcher that matches the given matcher a number of times in a row, within a range. |
| RepeatedChars(Func<char, bool>?, bool) | Creates a matcher that matches one or more consecutive occurrences of the same character. |
| RepeatedChars(int, int, Func<char, bool>?, bool) | Creates a matcher that matches between |
| RepeatedGroups(int, int, int, Func<char, bool>?, bool) | Creates a matcher that matches a short group of characters repeated consecutively, such as "121212" or "abab". |
| Sequence(IEnumerable<PasswordMatcher>) | Creates a matcher that matches the given matchers one after another, in order. |
| Text(string, PasswordMatchType, bool, bool, bool) | Creates a matcher that matches a word or phrase, ignoring case and optionally allowing common character substitutions (such as "@" for "a"). |