Soenneker.Utils.Password
11.0.1332
Prefix Reserved
dotnet add package Soenneker.Utils.Password --version 11.0.1332
NuGet\Install-Package Soenneker.Utils.Password -Version 11.0.1332
<PackageReference Include="Soenneker.Utils.Password" Version="11.0.1332" />
<PackageVersion Include="Soenneker.Utils.Password" Version="11.0.1332" />
<PackageReference Include="Soenneker.Utils.Password" />
paket add Soenneker.Utils.Password --version 11.0.1332
#r "nuget: Soenneker.Utils.Password, 11.0.1332"
#:package Soenneker.Utils.Password@11.0.1332
#addin nuget:?package=Soenneker.Utils.Password&version=11.0.1332
#tool nuget:?package=Soenneker.Utils.Password&version=11.0.1332
Soenneker.Utils.Password
A modern .NET secure password generator.
Installation
dotnet add package Soenneker.Utils.Password
Quick start
using Soenneker.Utils.Password;
Call the static PasswordUtil methods directly; no dependency-injection registration is required.
Fill a caller-owned buffer
using System.Runtime.InteropServices;
using System.Security.Cryptography;
Span<char> password = stackalloc char[32];
try
{
PasswordUtil.GetPassword(
password,
includeLowers: true,
includeUppers: true,
includeNumbers: true,
includeSpecials: true,
excludeAmbiguous: true);
UsePassword(password);
}
finally
{
CryptographicOperations.ZeroMemory(MemoryMarshal.AsBytes(password));
}
GetPassword fills the entire destination, guarantees at least one character from every enabled
class, fills the remainder from the combined alphabet, and securely shuffles the result. The
destination must be at least as long as the number of enabled classes. At least one class must be
enabled.
The special-character alphabet is !@#$%^*()[]{},.:~_-=. Ambiguous filtering applies to the
letter and number alphabets; it does not modify the special alphabet.
URI-safe passwords
Span<char> token = stackalloc char[24];
PasswordUtil.GetUriSafePassword(token, excludeAmbiguous: true);
try
{
UseToken(token);
}
finally
{
CryptographicOperations.ZeroMemory(MemoryMarshal.AsBytes(token));
}
The URI-safe methods use only ASCII lowercase letters, uppercase letters, and digits. They do not perform URL encoding and do not include punctuation.
String convenience methods
string password = PasswordUtil.GetPasswordString(length: 32);
string token = PasswordUtil.GetUriSafePasswordString(length: 24);
string digits = PasswordUtil.GetSecureCharacters(8, "0123456789");
GetSecureCharacters samples uniformly from the supplied alphabet without modulo bias, but it
does not guarantee every character or category appears. Its overload accepting a
RandomNumberGenerator leaves that caller-owned generator open.
The string-returning methods are convenient, but managed strings cannot be reliably cleared from
memory. Prefer the span overloads for secrets whose lifetime you need to limit, and securely clear the
buffer in a finally block. Clearing the caller's buffer cannot erase copies already made by
logging, interpolation, encoding, or another API.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Spans.Chars (>= 11.0.63)
- Soenneker.Extensions.Spans.Generics (>= 11.0.40)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1332 | 339 | 11/11/2026 |
| 11.0.1331 | 82 | 11/11/2026 |
| 11.0.1330 | 99 | 11/11/2026 |
| 11.0.1329 | 91 | 11/11/2026 |
| 11.0.1327 | 1,076 | 10/27/2026 |
| 11.0.1325 | 146 | 10/26/2026 |
| 11.0.1324 | 130 | 10/26/2026 |
| 11.0.1323 | 109 | 10/26/2026 |
| 4.0.1322 | 608 | 10/15/2026 |
| 4.0.1321 | 107 | 10/14/2026 |
| 4.0.1320 | 108 | 10/14/2026 |
| 4.0.1319 | 108 | 10/14/2026 |
| 4.0.1318 | 104 | 10/14/2026 |
| 4.0.1316 | 102 | 10/14/2026 |
| 4.0.1310 | 102 | 10/13/2026 |
| 4.0.1309 | 105 | 10/13/2026 |
| 4.0.1306 | 125 | 10/12/2026 |
| 4.0.1305 | 108 | 10/11/2026 |
| 4.0.1303 | 112 | 10/11/2026 |
| 4.0.1302 | 397 | 9/25/2026 |
Updated Multiple NuGet packages