{"id":15011540,"url":"https://github.com/spamok/spamok.passwordgenerator","last_synced_at":"2025-04-12T03:43:51.746Z","repository":{"id":236979015,"uuid":"793553423","full_name":"SpamOK/SpamOK.PasswordGenerator","owner":"SpamOK","description":"Secure (diceware) password generator for .NET.","archived":false,"fork":false,"pushed_at":"2024-12-13T13:16:12.000Z","size":360,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T23:23:22.543Z","etag":null,"topics":["diceware","dotnet","generator","library","nuget","password","password-generator","secure-password"],"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/SpamOK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-29T12:46:05.000Z","updated_at":"2024-12-13T11:32:17.000Z","dependencies_parsed_at":"2024-05-13T14:49:36.948Z","dependency_job_id":"d98a3164-2c6d-42ba-9ed8-84e1fdd88133","html_url":"https://github.com/SpamOK/SpamOK.PasswordGenerator","commit_stats":{"total_commits":69,"total_committers":2,"mean_commits":34.5,"dds":"0.18840579710144922","last_synced_commit":"a09bc2796227643a88b0a9d5c962341f632f73fa"},"previous_names":["spamok/spamok.passwordgenerator"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpamOK%2FSpamOK.PasswordGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpamOK%2FSpamOK.PasswordGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpamOK%2FSpamOK.PasswordGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpamOK%2FSpamOK.PasswordGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpamOK","download_url":"https://codeload.github.com/SpamOK/SpamOK.PasswordGenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514211,"owners_count":21116899,"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":["diceware","dotnet","generator","library","nuget","password","password-generator","secure-password"],"created_at":"2024-09-24T19:41:13.640Z","updated_at":"2025-04-12T03:43:51.727Z","avatar_url":"https://github.com/SpamOK.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/SpamOK/SpamOK.PasswordGenerator/assets/6917405/2e49a46f-5e53-4e7a-988b-94156bd83d15\"\u003e\n      \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/SpamOK/SpamOK.PasswordGenerator/assets/6917405/300e3ad2-4217-4479-8609-4d56733cf8ab\"\u003e\n      \u003cimg width=\"600px\" alt=\"Logo\" src=\"https://github.com/SpamOK/SpamOK.PasswordGenerator/assets/6917405/300e3ad2-4217-4479-8609-4d56733cf8ab\"\u003e\n    \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[\u003cimg src=\"https://img.shields.io/github/v/release/SpamOK/SpamOK.PasswordGenerator?include_prereleases\u0026logo=github\"\u003e](https://www.nuget.org/packages/SpamOK.PasswordGenerator)\n[![NuGet Version](https://img.shields.io/nuget/v/SpamOK.PasswordGenerator.svg?logo=nuget)](https://www.nuget.org/packages/SpamOK.PasswordGenerator)\n[\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/SpamOK/SpamOK.PasswordGenerator/dotnet-build-run-tests.yml?label=tests\"\u003e](https://github.com/SpamOK/SpamOK.PasswordGenerator/actions/workflows/dotnet-build-run-tests.yml) [\u003cimg src=\"https://img.shields.io/sonar/coverage/SpamOK_SpamOK.PasswordGenerator?server=https%3A%2F%2Fsonarcloud.io\u0026label=test code coverage\"\u003e](https://sonarcloud.io/summary/new_code?id=SpamOK_SpamOK.PasswordGenerator) [\u003cimg src=\"https://img.shields.io/sonar/quality_gate/SpamOK_SpamOK.PasswordGenerator?server=https%3A%2F%2Fsonarcloud.io\u0026label=sonarcloud\u0026logo=sonarcloud\"\u003e](https://sonarcloud.io/summary/new_code?id=SpamOK_SpamOK.PasswordGenerator) [\u003cimg src=\"https://img.shields.io/nuget/dt/SpamOK.PasswordGenerator?label=nuget downloads\u0026logo=nuget\"\u003e](https://www.nuget.org/packages/SpamOK.PasswordGenerator)\n\n\u003c/div\u003e\n\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\n**SpamOK.PasswordGenerator** is an open-source .NET library designed to generate highly secure, customizable and random passwords. It helps developers ensure their applications adhere to best practices in password security.\n\nThe library supports two password generation methods: basic password generation and [Diceware](https://theworld.com/~reinhold/diceware.html) passphrase generation. The basic password generation method allows you to generate passwords with a configurable length and includes options for numbers, special characters, and uppercase/lowercase differentiation. The Diceware passphrase generation method generates passwords using a list of words from a wordlist, with options for word capitalization, word separation, and salt addition.\n\n## 🖥️ Live demo\nYou can see the library in action on the official SpamOK website:\n[https://spamok.com/static/tools/password-generator](https://spamok.com/static/tools/password-generator)\n\n## Features\nThis library is designed to be easy to use and highly configurable, allowing developers to generate passwords that meet their specific requirements. The library is also fully unit tested, ensuring that it is reliable and robust.\n\nThis library features cryptographically secure random number generation. Additionally it provides generic helper methods\nfor things such as checking password strength, hackerifying strings and more.\n\n### Basic password generation\n- Generate random passwords with a configurable length.\n- Include numbers, special characters, and uppercase/lowercase differentiation.\n- Exclude specific characters from the password.\n- Use non-ambiguous characters to avoid confusion between similar characters (e.g., 'l' and '1').\n\n### Diceware passphrase generation\n- Generate passwords using a list of words from a wordlist.\n- Configure the amount of words, word capitalization, word separation, and salt addition.\n- Supports multiple languages, including:\n  - English\n  - Dutch\n  - German\n  - French\n  - Spanish\n  - Italian\n  - Ukrainian.\n\n## Installation\n\nTo install SpamOK.PasswordGenerator, use the following NuGet command:\n\n```bash\nInstall-Package SpamOK.PasswordGenerator -Version 1.1.0\n```\n\n## Usage\nBelow you can find examples of how to generate passwords using this library.\nThe PasswordGenerator classes apply the builder pattern, allowing you to set various options before generating the password.\n\n### 1. Basic password\nGenerating a basic password is done as follows:\n```csharp\nvar passwordBuilder = new SpamOK.PasswordGenerator.BasicPasswordBuilder();\nstring password = passwordBuilder\n    .SetLength(12)\n    .UseLowercaseLetters(true)\n    .UseUppercaseLetters(true)\n    .UseNumbers(true)\n    .UseSpecialChars(true)\n    .UseNonAmbiguousChars(false)\n    .ExcludeChars(\"abcdefg\")\n    .GeneratePassword()\n    .ToString();\n\nConsole.WriteLine(password);\n// \u003e\u003e\u003e Output: \"y)Q-#vm0!YQ^\"\n```\n\n#### Enable/disable all options\n\nInstead of enabling or disabling each option individually, you can use the\nDisableAllOptions() and EnableAllOptions() methods to quickly set all options to a specific state.\n\nThis example will disable all options and then enable lowercase letters only:\n\n```csharp\nvar passwordBuilder = new SpamOK.PasswordGenerator.BasicPasswordBuilder();\nstring password = passwordBuilder\n    .DisableAllOptions()\n    .UseLowercaseLetters(true)\n    .GeneratePassword()\n    .ToString();\n\nConsole.WriteLine(password);\n// \u003e\u003e\u003e Output: \"wlxbuqwb\"\n```\n\n#### Async method\n\nIf you are calling the GeneratePassword() method from an async client (e.g. Blazor), you can use the GeneratePasswordAsync() method instead which is awaitable:\n\n```csharp\nvar passwordBuilder = new SpamOK.PasswordGenerator.BasicPasswordBuilder();\n\n// Retrieve the password object via the async method which is awaitable.\nvar passwordObject = await passwordBuilder.GeneratePasswordAsync();\n\n// Get the actual password string from the object.\nvar passwordString = passwordObject.ToString();\n\nConsole.WriteLine(passwordString);\n// \u003e\u003e\u003e Output: \"wlxbuqwb\"\n```\n\n### 2. Diceware passphrase generation\nDiceware passphrase generation is a method of generating passwords using a dictionary. The words are selected randomly from the dictionary and concatenated to form a passphrase.\nYou can read more about Diceware passphrases [here](https://en.wikipedia.org/wiki/Diceware).\n\nThis library supports Diceware in multiple languages, including English, Dutch, German, French, Italian, Spanish and Ukrainian. The default language is English.\n\nBasic usage is as follows:\n```csharp\nusing SpamOK.PasswordGenerator.Algorithms.Diceware;\n\nvar passwordBuilder = new SpamOK.PasswordGenerator.DicewarePasswordBuilder();\nstring password = passwordBuilder\n    .SetLength(5)\n    .SetWordList(DicewareWordList.English)\n    .SetSeparator(DicewareSeparator.Dash)\n    .SetCapitalization(DicewareCapitalization.TitleCase)\n    .SetSalt(DicewareSalt.Sprinkle)\n    .HackerifyPassword(false)\n    .GeneratePassword()\n    .ToString();\n\nConsole.WriteLine(password);\n// \u003e\u003e\u003e Output: \"Crow-Sea-Wean-Farmu-Dawn\"\n```\n\n#### Simple variant using default values\nIf you wish to generate a diceware password using all default values, then you can directly call the GeneratePassword() method without setting any options:\n\n```csharp\nvar passwordBuilder = new SpamOK.PasswordGenerator.DicewarePasswordBuilder();\nstring password = passwordBuilder.GeneratePassword().ToString();\n\nConsole.WriteLine(password);\n// Output: \"green-game-glow-wage-wonder\"\n```\n\n#### Async method\n\nIf you are calling the GeneratePassword() method from an async client (e.g. Blazor), you can use the GeneratePasswordAsync() method instead which is awaitable:\n\n```csharp\nvar passwordBuilder = new SpamOK.PasswordGenerator.DicewarePasswordBuilder();\n\n// Retrieve the password object via the async method which is awaitable.\nvar passwordObject = await passwordBuilder.GeneratePasswordAsync();\n\n// Get the actual password string from the object.\nvar passwordString = passwordObject.ToString();\n\nConsole.WriteLine(passwordString);\n// \u003e\u003e\u003e Output: \"green-game-glow-wage-wonder\"\n```\n\n### 3. Password model\nBoth the BasicPasswordBuilder and DicewarePasswordBuilder classes return a Password object. This object contains the generated password as a string, as well information about the password's strength.\nThe following example demonstrates how to access the password and strength properties:\n\n```csharp\nusing SpamOK.PasswordGenerator.Helpers;\n\nvar passwordBuilder = new SpamOK.PasswordGenerator.BasicPasswordBuilder();\nvar passwordObject = passwordBuilder\n    .EnableAllOptions()\n    .SetLength(10)\n    .GeneratePassword();\n\n// Get the password as a string.\nConsole.WriteLine(passwordObject.ToString());\n// \u003e\u003e\u003e Output: \"^8Ap%|]#,3\"\n\n// Get the password's strength indicator as Enum.\nConsole.WriteLine(passwordObject.GetEntropy().GetPasswordStrength());\n// \u003e\u003e\u003e Output: PasswordStrength.Strong\n\n// Get the amount of time it would take to crack the password in seconds with\n// a - very - conservative assumption of 1 trillion guesses per second.\nConsole.WriteLine(passwordObject.GetEntropy().GetTimeToCrackSeconds());\n// \u003e\u003e\u003e Output: 2815676 (= 32 days)\n```\n\n## Contributing\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n* Fork the Project\n* Create your Feature Branch (**git checkout -b feature/AmazingFeature**)\n* Commit your Changes (**git commit -m 'Add some AmazingFeature'**)\n* Push to the Branch (**git push origin feature/AmazingFeature**)\n* Open a Pull Request\n\n### Building the project locally\nThe SpamOK.PasswordGenerator library itself targets .NET Standard 2.0 which means it works on both .NET Framework and the modern .NET 6.0/7.0/8.0+.\n\nHowever the test project uses .NET 8.0 as the targeting framework which means .NET 8.0 needs to be installed on your machine in order to run tests.\n\n#### Full compatibility list for local development:\n- Visual Studio 2022 / JetBrains Rider 2024.1+\n- .NET 8.0+\n\n### Running tests locally\nThis project uses NUnit for testing. To run the tests, use the following command:\n\n```bash\ndotnet test\n```\n\nTo run the tests with code coverage statistics, use the following command:\n\n```bash\ndotnet test -c Release /p:CollectCoverage=true /p:CoverletOutput=coverage /p:CoverletOutputFormat=opencover\n```\n\n## License\nThis project is licensed under the MIT License - see the LICENSE.md file for details.\n\n## Credits\nCredits belong to the following sources that are used in this project:\n\n- NL Diceware wordlist: https://mko.re/diceware/diceware-wordlist-8k-composites-nl.txt\n- EN Diceware wordlist: https://theworld.com/~reinhold/diceware8k.txt\n- DE Diceware wordlist: https://github.com/dys2p/wordlists-de\n- FR Diceware wordlist: https://github.com/ArthurPons/diceware-fr-alt\n- ES Diceware wordlist: https://github.com/mir123/dadoware-bonito-es/blob/master/DW-es-bonito.csv\n- IT Diceware wordlist: https://www.taringamberini.com/downloads/diceware_it_IT/lista-di-parole-diceware-in-italiano/4/word_list_diceware_it-IT-4.txt\n- UK Diceware wordlist: ChatGPT 4\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspamok%2Fspamok.passwordgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspamok%2Fspamok.passwordgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspamok%2Fspamok.passwordgenerator/lists"}