Meziantou.Framework.Http.Htpasswd 2.0.6

Prefix Reserved
dotnet add package Meziantou.Framework.Http.Htpasswd --version 2.0.6
                    
NuGet\Install-Package Meziantou.Framework.Http.Htpasswd -Version 2.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.Http.Htpasswd" Version="2.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.Http.Htpasswd" Version="2.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.Http.Htpasswd" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.Http.Htpasswd --version 2.0.6
                    
#r "nuget: Meziantou.Framework.Http.Htpasswd, 2.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.Http.Htpasswd@2.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.Http.Htpasswd&version=2.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.Http.Htpasswd&version=2.0.6
                    
Install as a Cake Tool

Meziantou.Framework.Http.Htpasswd

This package parses Apache htpasswd files and verifies credentials.

VerifyCredentials rejects any password longer than 1024 characters, because the cost of the crypt algorithms grows quadratically with the length of the supplied password.

Supported password formats:

  • bcrypt ($2a$, $2b$, $2y$)
  • Apache MD5 ($apr1$)
  • MD5 crypt ($1$)
  • SHA-256 crypt ($5$)
  • SHA-512 crypt ($6$)
  • SHA-1 ({SHA})
  • plaintext (opt-in, see Plaintext passwords)

{SHA} and plaintext entries are unsalted, so they are only there to read existing files. Use bcrypt for new ones.

var htpasswd = HtpasswdFile.Parse("""
        alice:$2y$10$bXuOalpYagnenorrJU65m.z5VzYstr4rBZl2WUHNwhGjItODNoDrG
        bob:{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=
        """);

var isAliceValid = htpasswd.VerifyCredentials("alice", "password");
var isBobValid = htpasswd.VerifyCredentials("bob", "password");
Assert.True(isAliceValid);
Assert.True(isBobValid);

Plaintext passwords

An entry whose format is not recognized is rejected. Pass allowPlaintextPasswords: true to compare it against the supplied password as plaintext instead:

var htpasswd = HtpasswdFile.Parse("alice:password", allowPlaintextPasswords: true);
Assert.True(htpasswd.VerifyCredentials("alice", "password"));

Enabling this also makes hashes the library does not implement, such as traditional DES crypt (htpasswd -d), match when the stored hash itself is supplied as the password. Leave it disabled unless the file really does contain plaintext passwords.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.6 149 10/28/2026
2.0.5 90 10/21/2026
2.0.4 119 9/13/2026
2.0.3 124 9/6/2026
2.0.2 115 8/30/2026
2.0.1 126 7/8/2026
2.0.0 132 7/5/2026
1.0.3 127 6/13/2026
1.0.2 125 5/23/2026
1.0.1 248 4/25/2026
1.0.0 184 3/1/2026