Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/picrap/pbkdf2
Flexible implementation for PBKDF2 (RFC2898)
https://github.com/picrap/pbkdf2
pbkdf2
Last synced: about 2 months ago
JSON representation
Flexible implementation for PBKDF2 (RFC2898)
- Host: GitHub
- URL: https://github.com/picrap/pbkdf2
- Owner: picrap
- License: mit
- Created: 2022-11-20T10:03:52.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T11:11:22.000Z (about 2 years ago)
- Last Synced: 2024-04-27T08:35:37.705Z (8 months ago)
- Topics: pbkdf2
- Language: C#
- Homepage:
- Size: 116 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Pbkdf2
The same as [.NET implementation](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.rfc2898derivebytes), but with much more extensibility, such as other hashes and the ability to replace any algorithm part (at your own risk).
Available as a [![NuGet](https://img.shields.io/nuget/v/Pbkdf2.svg?style=flat-square)](https://www.nuget.org/packages/Pbkdf2) package.# How to use it
## Simple way
```csharp
var saltBytes = new byte [] {1, 2, 3, 4, 5}; // use much more than this!
var hash = Pbkdf2.HashData("HMACSHA512", "my password", saltBytes,
100000 /* iterations */, 32 /* hash size in bytes */);
```## Full way
```csharp
var saltBytes = new byte [] {1, 2, 3, 4, 5}; // use much more than this!
using var pbkdf2 = new HmacPbkdf2DeriveBytes("HMACSHA512", "my password", saltBytes,
100000 /* iterations */);
var hash = pbkdf2.GetBytes(32 /* hash size in bytes */);
```## Derive
All methods can be overriden so any part of hash can be replaced.
The idea is to avoid being brute forced by an ASIC, for example by simply adding a user block manipulation at `PseudoRandomFunction` or `ComputeBlockIteration`.Currently there are three classes:
- `Pbkdf2DeriveBytes` is the abstract class which requires only to add a pseudo-random function
- `HmacPbkdf2DeriveBytes` is an implementation of `Pbkdf2DeriveBytes`, specific to use HMACs.
- `ParallelHmacPbkdf2DeriveBytes` is an implementation of `Pbkdf2DeriveBytes`, specific to use HMACs and work in parallel (using PLINQ).# References
- [RFC 2898](https://www.rfc-editor.org/rfc/rfc2898): the reference
- [.NET implementation documentation](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.rfc2898derivebytes): our implementation works the same
- [Wikipedia](https://en.wikipedia.org/wiki/PBKDF2): a human-readable description