Reimplementation of SimpleCrypto.Net as a .Net Standard Library. Provides easy use of the PBKDF2 algorithm.
Create a nuget package called SimpleCrypto.Standard
that is fully compatible to the mentioned SimpleCrypto.Net library.
The library wraps around the PBKDF2 implementation of C# and provides easy access to generate secure hashs.
You can find this package on Nuget. To install the latest version via the Package Manager Console use
PM> Install-Package SimpleCrypto.Standard
If you prefer to user the .NET CLI use
> dotnet add package SimpleCrypto.Standard
Version 0.2.x
requires Net Standard 2.0. Future versions require Net Standard 2.1
Version 0.2.1
introduces the InsecureOperationException
. This could potentially make usage complicated when until now an insecure configuration was used.
You can find a basic example in the SimpleCrypto.ConsoleSample
Project.
IPbkdf2 pbkdf2 = new Pbkdf2();
string password = "MySecretPassword"
// Compute the hash of the password. As no Salt is provided the call will generate the Salt.
string hash = pbkdf2.Compute(password);
//Additional to the hash, you have to save the Salt. You can access it via a Property of the pbkdf2 object.
string salt = pnkdf2.Salt
// Compare two hashs (or strings) in constant Time.
bool areEqual = pbkdf2.Compare(savedHash, computedHash);
The Compute
methode provides several overrides to allow different configurations. If the default overrides dont fit your needs,
you cant set the public properties you need.
For example: Compute the Hash with a Saltsize of 18 and an Iterationcount of 200 000 you can use the override:
string hash = pbkdf2.Compute("TextTohash", 18, 200000)
This exception will be thrown when the Compute
method gets called with insecure conditions.
The message contains further information what configuration exactly caused the exception