Isopoh.Cryptography.Argon2
GitHub Repository
https://github.com/mheyman/Isopoh.Cryptography.Argon2
Nuget Repositories
Library | Nuget Repository | Depends On |
---|---|---|
Argon2 | https://www.nuget.org/packages/Isopoh.Cryptography.Argon2/ | Blake2b, SecureArray |
Blake2b | https://www.nuget.org/packages/Isopoh.Cryptography.Blake2b/ | SecureArray |
SecureArray | https://www.nuget.org/packages/Isopoh.Cryptography.SecureArray/ |
To use Argon2 in your project, you can
Install-Package Isopoh.Cryptography.Argon2
or
dotnet add package Isopoh.Cryptography.Argon2
or
paket add Isopoh.Cryptography.Argon2
This project uses SourceLink so you should be able to step into the source code for debugging even when just adding the NuGet package as a dependency.
Argon2 Package Introduction
Fully managed .Net implementation of the Argon2 (reference implementation) hashing algorithm designed to be a good choice for hashing passwords for credential storage or key derivation because of its resistance to many attacks.
Typical Usage
Hash with:
var hash = Argon2.Hash("my password");
Verify with:
if (Argon2.Verify(hash, "my password"))
{
// ...
}
or
if (Argon2.Verify(hash, "my password", Environment.ProcessorCount))
{
// ...
}
Note, using something like (1 + Environment.ProcessorCount)/2
for the
threads
parameter can keep the hash calculation from hammering the system if
it is performing a lot of hashes. Also, until it is working, don't use a
value other than 1
for the threads
parameter when performing Argon2 hashes
in a web page.
SecureArray
This library includes an implementation of a SecureArray
which is designed to hold sensitive information. Depending on policy, data
in a SecureArray
will not be moved or swapped to disk and will always be
zeroed when disposed. WebAssembly doesn't allow for move or swap prevention
so, when running in a web page, only zero-upon-disposal protection exists.
Blake2b
This library also contains a Blake2b hash based on the C# reference
implementation found here but modified to
use SecureArray
where appropriate.
Running In A Web Page
This library can be used to run in a web page via Blazor or Uno Platform.
A quick introduction to that is at Argon2 in WebAssembly.