Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Security.​Cryptography.​Rfc2898DeriveBytes

Assembly: System.Security.Cryptography

Inheritance: object → DeriveBytes → Rfc2898DeriveBytes

Implemented Interfaces

Implements password-based key derivation functionality, PBKDF2, by using a pseudo-random number generator based on <see cref="T:System.Security.Cryptography.HMACSHA1" /> .

Properties

HashAlgorithm
Gets the hash algorithm used for byte derivation.
public int
IterationCount
Gets or sets the number of iterations for the operation.
public byte[]
Salt
Gets or sets the key salt value for the operation.

Methods

public byte[]
CryptDeriveKey​(string algname, string alghashname, int keySize, byte[] rgbIV)
Derives a cryptographic key from the <see cref="T:System.Security.Cryptography.Rfc2898DeriveBytes" /> object.
Returns The derived key.
algname The algorithm name for which to derive the key.
alghashname The hash algorithm name to use to derive the key.
keySize The size of the key, in bits, to derive.
rgbIV The initialization vector (IV) to use to derive the key.
protected void
Dispose​(bool disposing)
Releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.Rfc2898DeriveBytes" /> class and optionally releases the managed resources.
disposing <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
public byte[]
GetBytes​(int cb)
Returns the pseudo-random key for this object.
Returns A byte array filled with pseudo-random key bytes.
cb The number of pseudo-random key bytes to generate.
public static byte[]
Pbkdf2​(byte[] password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Creates a PBKDF2 derived key from password bytes.
Returns A byte array containing the created PBKDF2 derived key.
password The password used to derive the key.
salt The key salt used to derive the key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
outputLength The size of the key to derive, in bytes.
public static byte[]
Pbkdf2​(ReadOnlySpan<​byte> password, ReadOnlySpan<​byte> salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Creates a PBKDF2 derived key from password bytes.
Returns A byte array containing the created PBKDF2 derived key.
password The password used to derive the key.
salt The key salt used to derive the key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
outputLength The size of the key to derive, in bytes.
public static void
Pbkdf2​(ReadOnlySpan<​byte> password, ReadOnlySpan<​byte> salt, Span<​byte> destination, int iterations, HashAlgorithmName hashAlgorithm)
Fills a buffer with a PBKDF2 derived key.
password The password used to derive the key.
salt The key salt used to derive the key.
destination The buffer to fill with a derived key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
public static byte[]
Pbkdf2​(ReadOnlySpan<​char> password, ReadOnlySpan<​byte> salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Creates a PBKDF2 derived key from a password.
Returns A byte array of length <paramref name="outputLength" /> that is filled with pseudo-random key bytes.
password The password used to derive the key.
salt The key salt used to derive the key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
outputLength The size of the key to derive, in bytes.
public static void
Pbkdf2​(ReadOnlySpan<​char> password, ReadOnlySpan<​byte> salt, Span<​byte> destination, int iterations, HashAlgorithmName hashAlgorithm)
Fills a buffer with a PBKDF2 derived key.
password The password used to derive the key.
salt The key salt used to derive the key.
destination The buffer to fill with a derived key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
public static byte[]
Pbkdf2​(string password, byte[] salt, int iterations, HashAlgorithmName hashAlgorithm, int outputLength)
Creates a PBKDF2 derived key from a password.
Returns A byte array of length <paramref name="outputLength" /> that is filled with pseudo-random key bytes.
password The password used to derive the key.
salt The key salt used to derive the key.
iterations The number of iterations for the operation.
hashAlgorithm The hash algorithm to use to derive the key.
outputLength The size of the key to derive, in bytes.
public void
Reset​()
Resets the state of the operation.
public void
Dispose​()
Inherited from DeriveBytes
When overridden in a derived class, releases all resources used by the current instance of the <see cref="T:System.Security.Cryptography.DeriveBytes" /> class.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object