Pbkdf2 Class

CryptSharp

Pbkdf2 Class CryptSharp
Implements the PBKDF2 key derivation function.
Inheritance Hierarchy

SystemObject  SystemMarshalByRefObject
    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

  NameDescription
Public methodPbkdf2
Creates a new PBKDF2 stream.
Top
Methods

  NameDescription
Public methodClose
Closes the stream, clearing memory and disposing of the HMAC algorithm.
(Overrides StreamClose.)
Public methodStatic memberComputeDerivedKey
Computes a derived key.
Public methodRead(Int32)
Reads from the derived key stream.
Public methodRead(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).)
Public methodSeek
When overridden in a derived class, sets the position within the current stream.
(Overrides StreamSeek(Int64, SeekOrigin).)
Top
Properties

  NameDescription
Public propertyLength
The maximum number of bytes that can be derived is 2^32-1 times the HMAC size.
(Overrides StreamLength.)
Public propertyPosition
The position within the derived key stream.
(Overrides StreamPosition.)
Top
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

Reference