{"id":20931331,"url":"https://github.com/havardt/passwordvalidator","last_synced_at":"2025-05-13T19:33:16.590Z","repository":{"id":65413157,"uuid":"173461064","full_name":"havardt/PasswordValidator","owner":"havardt","description":"A .NET standard library for advanced password validation.","archived":false,"fork":false,"pushed_at":"2024-05-24T19:35:42.000Z","size":91,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-05T02:15:57.362Z","etag":null,"topics":["csharp","easy-to-use","library","password","password-validation","password-validator","validator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/havardt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-02T14:58:27.000Z","updated_at":"2024-07-16T04:07:16.000Z","dependencies_parsed_at":"2023-01-31T11:46:00.021Z","dependency_job_id":null,"html_url":"https://github.com/havardt/PasswordValidator","commit_stats":null,"previous_names":["havardt/ezpasswordvalidator"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardt%2FPasswordValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardt%2FPasswordValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardt%2FPasswordValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardt%2FPasswordValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/havardt","download_url":"https://codeload.github.com/havardt/PasswordValidator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254013144,"owners_count":21999365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","easy-to-use","library","password","password-validation","password-validator","validator"],"created_at":"2024-11-18T21:41:22.171Z","updated_at":"2025-05-13T19:33:16.244Z","avatar_url":"https://github.com/havardt.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e **Warning**    \n\u003e This package has been deprecated as it is no longer maintained.\n\n# PasswordValidator      \n[![NuGet version (EzPasswordValidator)](https://img.shields.io/nuget/v/EzPasswordValidator.svg)](https://www.nuget.org/packages/EzPasswordValidator/)\n[![Downloads](https://img.shields.io/nuget/dt/EzPasswordValidator)](https://www.nuget.org/packages/EzPasswordValidator/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)    \n\nA .NET standard library for easy password validation.\nThis library defines 11 predefined checks and an easy way to implement custom checks.     \n\n## :scroll: Table of contents :scroll:\n* [Predefined checks](#Checks)\n* [Install](#Install)\n* [Usage](#Usage)\n* [How to contribute](#Contribute)\n* [License info](#License)\n\n## Checks\nThere are 11 predfined checks each representing a password criteria. Each check type is defined as a bit flag. A combination of checks can thus be simply refrenced using a single integer. All predefined check types are defined [here.](source/EzPasswordValidator/Checks/CheckTypes.cs)\n\n\u003e **NIST Special Publication [800-63B](https://pages.nist.gov/800-63-3/sp800-63b.html#AAL_SEC5)**              \n\u003e The following are the key takeaways from these guidelines:\n\u003e - SHALL ensure that passwords are at least 8 characters in length and MAY all be numeric.\n\u003e - SHALL permit passwords at least 64 characters in length.\n\u003e - SHALL disallow passwords that appear on a blacklist of commonly-used or compromised values.\n\u003e - SHOULD not enforce any other constraints.    \n\u003e\n\n#### Length check (CheckTypes.Length)\nChecks if the given password is equal to or longer than the required minimum length\nand equal to or shorter than the maximum allowed length.     \n```\nDefault minimum length: 8     \nDefault maximum length: 128\n```\n\nChanging length bounds example:\n\n```C#\nvalidator.MinLength = 10;\nvalidator.MaxLength = 256;\n\n//OR\n\nvalidator.SetLengthBounds(10, 256);\n```\n\n#### Check for numbers (CheckTypes.Numbers)\nChecks that the password contains at least one digit.\n\n#### Check for letters (CheckTypes.Letters)\nChecks that the password contains at least one letter. This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.\n\n#### Check for symbols (CheckTypes.Symbols)\nChecks that the password contains at least one symbol.\n\n#### Case check (CheckTypes.CaseUpperLower)\nChecks that the password contains at least one upper- and lower-case letter. This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.\n\n#### Check for number sequences (CheckTypes.NumberSequence)\nChecks if the password contains a number series/sequence equal to or longer than the set length. This length can be updated by setting the          ```EzPasswordValidator.Validators.PasswordValidator.NumberSequenceLength``` property (from v2.0.0). By default this has the following values: \n\nDefault number sequence length (version \u003c 2.0.0): 3     \nDefault number sequence length (version \u003e= 2.0.0): 4    \n\nBoth increasing sequences and decreasing sequences are checked.\n\n```\nExample number sequence: 12345  or  987654321\n```\n\n#### Check for number repetition (CheckTypes.NumberRepetition)  \n\u003cb\u003e This type has been replaced with digit repetition from v2.0.0\u003c/b\u003e  \n\nChecks if the password contains number repetition equal to or longer than 3 in a row.\n\n```\nExample number repetition: 444  or  222\n```\n\n#### Check for digit repetition (CheckTypes.DigitRepetition) - New in v2.0.0\nChecks if the password contains digit repetition equal to or longer than the set length. This length can be updated by setting the          ```EzPasswordValidator.Validators.PasswordValidator.DigitRepetitionLength``` property. By default this has the following values: \n   \nDefault digit repetition length: 4    \n```\nExample digit repetition: 4444  or  2222\n```\n\n#### Check for number location (CheckTypes.NumberMixed)\nChecks that the password does not only have numbers in the front and/or end of the password. To pass this check the password must have a non-digit character before and after a digit character, only one digit must match this pattern.\n```\nExample invalid password: 2password   |  password2\nExample valid   password: 2pass9word  |  p6ssword\n```\n\n#### Check for letter sequences (CheckTypes.LetterSequence)\nChecks if the password contains an alphabetical letter sequence consisting of a set amount of letters or more. This length can be updated by setting the  ```EzPasswordValidator.Validators.PasswordValidator.LetterSequenceLength``` property (from v2.0.0). By default this has the following values: \n   \nDefault letter sequence length: 4    \n\n\u003cb\u003eNote:\u003c/b\u003e this check currently only supports ISO basic latin alphabet (A-Z a-z).\n```\nExample letter sequence: abcd or bcde\n```\n\nFor versions prior to v2.0.0 two three letter sequences where also checked for: ```abc``` and ```xyz```.\n \n#### Check for letter repetition (CheckTypes.LetterRepetition)\nChecks if the password contains letter repetition of a set length or longer. This length can be updated by setting the  ```EzPasswordValidator.Validators.PasswordValidator.LetterRepetitionLength``` property (from v2.0.0). Prior to v2.0.0 this check had hardcoded a repetition of 3 or more letters.\n\n\u003cb\u003eNote:\u003c/b\u003e    \n- This check supports multiple alphabets. For more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.isletter?view=netframework-4.8#remarks) refrence.    \n- This check is not case sensitive meaning 'aAA' and 'aaa' are both classified as letter repetition of length 3.   \n```\nExample letter repetition: aAAA  or  bbbb\n```\n\n#### Check for symbol repetition (CheckTypes.SymbolRepetition)\nChecks if the password contains symbol repetition of a set length or longer. This length can be updated by setting the  ```EzPasswordValidator.Validators.PasswordValidator.SymbolRepetitionLength``` property (from v2.0.0). Prior to v2.0.0 this check had hardcoded a repetition of exactly 3 symbols.\n\nFor more information about how we classify a letter see [this](https://docs.microsoft.com/en-us/dotnet/api/system.char.issymbol?view=netframework-4.8#remarks) refrence.  \n```\nExample symbol repetiton of length 4: ////  or  @@@@\n```\n\n## Install\nThere are three main ways to install EzPasswordValidator:\n- [NuGet](https://www.nuget.org/packages/EzPasswordValidator/) (Recommended)\n- Download .dll from [releases](https://github.com/havardt/EzPasswordValidator/releases)\n- Manually build .dll from source\n\n\n## Usage\n\nFirst create a validator. The constructor is overloaded and can take ```CheckTypes```.\n\n```C#\nvar validator = new PasswordValidator(CheckTypes.Letters | CheckTypes.Numbers | CheckTypes.Length);\n```\n\nThis example shows the creation of a validator that checks that a password contains letters, numbers and is within the set length bounds(default length bounds, since it is not explicitly set).\n\n#### Validate\nThe ```Validate``` method runs through all the set checks and returns ```true``` if the password is valid according to the set criteria and ```false``` otherwise.\n\n```C#\nbool isValid = validator.Validate(password);\n```\n\n\u003ci\u003ePartial criteria matching\u003c/i\u003e     \nPartial criteria matching is a feature that allows a password to be validated even if only a subset of the checks pass. For example, if you add the check for letters, the check for numbers, and the check for upper and lower case, then you can pass a value of 2 to the validator indicating that the password is only required to pass two of these three checks. A password with letters and numbers, but no upper case is then still valid. You can also provide a value between 0 and 1 representing the % of checks that must pass.\n\n```C#\nbool isValid = validator.Validate(password, 2); // Two tests must pass for the password to be valid.\nbool isValid = validator.Validate(password, 0.5); // 50% of the tests must pass for the password to be valid.\n```\n\n\u003ci\u003eFailed checks\u003c/i\u003e     \nOne can iterate over the checks that failed by doing the following:\n```C#\nforeach (Check failedCheck in validator.FailedChecks)\n{\n    \n}\n```\n\n\u003ci\u003ePassed checks\u003c/i\u003e     \nOne can iterate over the checks that passed by doing the following:\n```C#\nforeach (Check passedCheck in validator.PassedChecks)\n{\n    \n}\n```\n\n#### Add checks\n\n\u003ci\u003eAdd single predefined check\u003c/i\u003e\n```C#\n validator.AddCheck(CheckTypes.LetterSequence);\n```\n\u003ci\u003eAdd custom check\u003c/i\u003e\u003cbr/\u003e\nCustom checks can be added in two ways:\n1. Anonymous method\n2. Create a class that inherits EzPasswordValidator.Checks.CustomCheck\n```C#\nvalidator.AddCheck(nameof(MyCustomCheck), MyCustomCheck);\n//or\nvalidator.AddCheck(\"MyCustomCheckTag\", psw =\u003e psw.Length \u003e 8);\n```\n\n\u003ci\u003eAdd multiple checks\u003c/i\u003e\nMultiple checks can be added at once as the ```CheckTypes``` are bit flags. See [CheckTypes](source/EzPasswordValidator/Checks/CheckTypes.cs) for a reference.\n\nAdd multiple checks by using bitwise OR:\n```C#\n validator.AddCheck(CheckTypes.NumberSequence | CheckTypes.LetterSequenceCheck);\n```\nThis adds both the number sequence check and the letter sequence check.\n\nAdd multiple checks by using a integer value:\n```C#\n validator.AddCheck(288);\n```\nHere the number sequence (binary: 100000) and letter sequence (binary: 100000000) checks are added as the combined binary value is ‭100100000‬ which is the same as 288 in base 10.\n\nThere are also two predefined combinations: basic and advanced.\nBasic contains length check, numbers check, letters check, symbols check, and upper-lower-case check.\nAdvanced contains all checks. These can be added by doing either of the following:\n\n```C#\n validator.AddCheck(CheckTypes.Basic);\n validator.AddCheck(CheckTypes.Advanced);\n```\n#### Remove checks\n\n```C#\nvalidator.RemoveCheck(CheckTypes.Symbols);\nvalidator.RemoveCheck(1); // 1 represents the length check\nvalidator.RemoveCheck(\"MyCustomCheckTag\"); // Removes the custom check with the given tag\n```\n\n## Contribute\nWe welcome all contributions, please see the [contribution guidelines](.github/CONTRIBUTING.md).\n\n## License\n\nThis project is licensed under the MIT License - see [LICENSE.md](LICENSE.md) for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavardt%2Fpasswordvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavardt%2Fpasswordvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavardt%2Fpasswordvalidator/lists"}