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
<PackageReference Include="Meziantou.Framework.Http.Htpasswd" Version="2.0.6" />
<PackageVersion Include="Meziantou.Framework.Http.Htpasswd" Version="2.0.6" />
<PackageReference Include="Meziantou.Framework.Http.Htpasswd" />
paket add Meziantou.Framework.Http.Htpasswd --version 2.0.6
#r "nuget: Meziantou.Framework.Http.Htpasswd, 2.0.6"
#:package Meziantou.Framework.Http.Htpasswd@2.0.6
#addin nuget:?package=Meziantou.Framework.Http.Htpasswd&version=2.0.6
#tool nuget:?package=Meziantou.Framework.Http.Htpasswd&version=2.0.6
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 | Versions 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. |
-
net10.0
- Meziantou.Framework.Hashing (>= 1.0.0)
-
net11.0
- Meziantou.Framework.Hashing (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.