Pbkdf2 Class | CryptSharp |
Implements the PBKDF2 key derivation function.
Inheritance Hierarchy
System.IOStream
CryptSharp.UtilityPbkdf2
Namespace: CryptSharp.Utility
Assembly: CryptSharp (in CryptSharp.dll) Version: 2.1.0.0
Syntax
public class Pbkdf2 : Stream
Public Class Pbkdf2 Inherits Stream
public ref class Pbkdf2 : public Stream
type Pbkdf2 = class inherit Stream end
The Pbkdf2 type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Pbkdf2 |
Creates a new PBKDF2 stream.
|
Methods
Name | Description | |
---|---|---|
Close |
Closes the stream, clearing memory and disposing of the HMAC algorithm.
(Overrides StreamClose.) | |
ComputeDerivedKey |
Computes a derived key.
| |
Read(Int32) |
Reads from the derived key stream.
| |
Read(Byte, Int32, Int32) | When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Overrides StreamRead(Byte, Int32, Int32).) | |
Seek | When overridden in a derived class, sets the position within the current stream. (Overrides StreamSeek(Int64, SeekOrigin).) |
Properties
Name | Description | |
---|---|---|
Length |
The maximum number of bytes that can be derived is 2^32-1 times the HMAC size.
(Overrides StreamLength.) | |
Position |
The position within the derived key stream.
(Overrides StreamPosition.) |
Examples
Computing a Derived Key
using System.Security.Cryptography; using CryptSharp.Utility; // Compute a 128-byte derived key using HMAC-SHA256, 1000 iterations, and a given key and salt. byte[] derivedKey = Pbkdf2.ComputeDerivedKey(new HMACSHA256(key), salt, 1000, 128);
Creating a Derived Key Stream
using System.IO; using System.Security.Cryptography; using CryptSharp.Utility; // Create a stream using HMAC-SHA512, 1000 iterations, and a given key and salt. Stream derivedKeyStream = new Pbkdf2(new HMACSHA512(key), salt, 1000);
See Also