{"id":23337447,"url":"https://github.com/smalls1652/pwsh.passwordgenerator","last_synced_at":"2026-04-28T21:04:53.583Z","repository":{"id":103561066,"uuid":"400009611","full_name":"Smalls1652/pwsh.PasswordGenerator","owner":"Smalls1652","description":"A secure random password generator for PowerShell 7.","archived":false,"fork":false,"pushed_at":"2021-09-30T03:38:09.000Z","size":2038,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T13:12:50.161Z","etag":null,"topics":["powershell"],"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/Smalls1652.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-26T01:55:45.000Z","updated_at":"2021-08-26T23:57:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd9b0d7d-a98c-47e8-86be-c8791d4463e9","html_url":"https://github.com/Smalls1652/pwsh.PasswordGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smalls1652%2Fpwsh.PasswordGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smalls1652%2Fpwsh.PasswordGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smalls1652%2Fpwsh.PasswordGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smalls1652%2Fpwsh.PasswordGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smalls1652","download_url":"https://codeload.github.com/Smalls1652/pwsh.PasswordGenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657266,"owners_count":20974345,"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":["powershell"],"created_at":"2024-12-21T02:17:27.560Z","updated_at":"2026-04-28T21:04:53.576Z","avatar_url":"https://github.com/Smalls1652.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Random password generator for PowerShell\n\n![Random password generation in action.](.repo-imgs/ctP09IJqz6.gif)\n\nEver wanted to make a _truly random*_ password in PowerShell? Well you can now. This is just a really spur of the moment side-project I started working on, because the static class `System.Web.Security.Membership`, which has the method `GeneratePassword(int length, int numberOfNonAlphanumericCharacters)`, is only available in .NET 2.0 through 4.8 and the `System.Random` class [isn't a secure way of randomly generating numbers](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca5394) (Though it might gain [_some_ security improvements in .NET 6.0](https://github.com/dotnet/runtime/blob/v6.0.0-preview.7.21377.19/src/libraries/System.Private.CoreLib/src/System/Random.cs#L218), but it's still a pseudo-random number generator). This random password generator should be compatible across all supported platforms for PowerShell 7.1, which I go into more detail in [this section](#under-the-hood).\n\n_**\\*** Random enough._\n\n## Requirements\n\n### Building\n\n* **.NET SDK** - Minimum of `5.0`.\n\n### Running\n\n* **PowerShell** - Minimum of `7.1`.\n  * **Note**: That's all I've tested it on and PowerShell 7.1 is based off of .NET 5, which is the target framework for compiling this.\n\n## How it works\n\nRight now it goes through these steps to generate a random password:\n\n1. Randomly decide if an individual character should be an Alpha (`A-Za-z`), Number (`0-9`), or Symbol (`@`, `#`, `!`, etc.) character.\n2. Randomly select a character from their respective character type.\n   - If the character randomly chosen is in the `-IgnoredCharacters` parameter, it will rerun that step.\n3. Merge all of the characters into a string and return it to the console.\n4. **???**\n5. Profit!\n\n### Under the hood\n\nIt utilizes the `System.Security.Cryptography` class `RandomNumberGenerator` to cryptographically choose the characters. .NET will choose how it randomly generates numbers depending on your platform:\n\n* **Windows** will use the [`BCryptGenRandom()`](https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom) function in the win32 API header `bcrypt.h`, which will default to what the system preferred algorithm is based off of your hardware.\n  * **Sources**:\n    * [`@dotnet/runtime/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RandomNumberGeneratorImplementation.Windows.cs`](https://github.com/dotnet/runtime/blob/v5.0.9/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RandomNumberGeneratorImplementation.Windows.cs#L14) (As of .NET 5.0.9)\n* **macOS** will use, what I believe (Correct me if I'm wrong), the [`SecRandomCopyBytes()`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes) function found in the [Apple Security Framework](https://developer.apple.com/documentation/Security).\n  * **Sources**:\n    * [`@dotnet/runtime/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RandomNumberGeneratorImplementation.OSX.cs`](https://github.com/dotnet/runtime/blob/v5.0.9/src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/RandomNumberGeneratorImplementation.OSX.cs#L14) (As of .NET 5.0.9)\n    * [.NET Core 2.0 Announcement that macOS will use the Apple Security Framework](https://github.com/dotnet/announcements/issues/21)\n* **Unix-based systems** will use, what I believe (Correct me if I'm wrong), the OpenSSL library for cryptographic operations and should be using the [`RAND_bytes()`](https://www.openssl.org/docs/manmaster/man3/RAND_bytes.html) function. OpenSSL should default to whatever entropy sources your OS and system supports.\n  * **Sources**:\n    * [`@dotnet/runtime/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs`](https://github.com/dotnet/runtime/blob/208e377a5329ad6eb1db5e5fb9d4590fa50beadd/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs#L17) (As of .NET 5.0.9)\n    * [`@dotnet/runtime/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs`](https://github.com/dotnet/runtime/blob/208e377a5329ad6eb1db5e5fb9d4590fa50beadd/src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs#L11) (As of .NET 5.0.9)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmalls1652%2Fpwsh.passwordgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmalls1652%2Fpwsh.passwordgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmalls1652%2Fpwsh.passwordgenerator/lists"}