A utility library for Argon2 hashing and verification
$ dotnet add package Soenneker.Hashing.Argon2
Soenneker.Hashing.Argon2dotnet add package Soenneker.Hashing.Argon2
string password = "SecurePassword123";
string hash = await Argon2HashingUtil.Hash(password);
// Result: A Base64-encoded hash string
Console.WriteLine(hash);
string password = "SecurePassword123";
string hash = await Argon2HashingUtil.Hash(password);
bool isValid = await Argon2HashingUtil.Verify(password, hash);
// Result: True if the password matches the hash
Console.WriteLine(isValid ? "Password is valid!" : "Invalid password.");
string password = "CustomPassword";
int saltSize = 32; // Custom salt size (bytes)
int hashSize = 64; // Custom hash size (bytes)
int iterations = 8; // Custom iteration count
int memorySize = 131072; // Custom memory size (KB)
int parallelism = 4; // Custom thread count
string hash = await Argon2HashingUtil.Hash(password, saltSize, hashSize, iterations, memorySize, parallelism);
bool isValid = await Argon2HashingUtil.Verify(password, hash, saltSize, hashSize, iterations, memorySize, parallelism);