TextConstraints is a few simple libraries for producing policies with regard to passwords and text validation written in C#.
A command-line password policy validator.
Password policies are constructed using a fluent interface.
Password policies can be extended with arbitrary rules to create more complex password policies that enforce more requirements.
Creating a more complex password policy.
Password policies can be evaluated quite simply, with a result object which can be evaluated to determine which rules passed and failed within the policy.
Evaluating text against a policy.
Custom rules can be created by implementing the ITextRule
interface.
A custom ITextRule
implementation.
Rules can then be added to a policy like any other rule.
Using a custom text rule in a policy.
A word tree is a compact mechanism used to store dictionaries for quick lookups.
This project serilies word trees in a binary format, via the following specificiation
[0..-1] = TreeNode[] : An array of all nodes contained within the tree.
Structure: TreeNode (3 bytes)
[0..0] = char : The character this node represents.
[1..2] = ushort : The amount of proceeding nodes that should be considered a child node of this one. +32768 if the node represents a full word.
All words in the Oxford English Dictionary found here in this tree format compresses down to ~372 KB. This may be quite larger than expected; but this is a search-optimized data structure. Other encodings like Huffman encoding on comma-seperated values will optimize for size more efficiantly.
Once loaded, a word tree can be quickly scanned to see whether a word is contained within a tree; and also list all elements in the tree past a given node.
Finding suggestions in a word tree.
This feature to be able to find words using a given prefix is how a lot of auto-complete tools can be implemented. Below is a console demo of this.
A command-line demonstration of word auto-completion.
⚠ This implementation of word trees cannot handle a single root letter containing more than 32,768 words.
⚠ This implementation of word trees only affords for a single ASCII byte for characters. Unicode is not supported.
To address the issues highlighted above; the data-structure can be increased in size.
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.