Export (0) Print
Expand All

Rfc2898DeriveBytes Constructor (Byte[], Byte[], Int32)

Note: This constructor is new in the .NET Framework version 2.0.

Initializes a new instance of the Rfc2898DeriveBytes class using a password, a salt, and number of iterations to derive the key.

Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)

public:
Rfc2898DeriveBytes (
	array<unsigned char>^ password, 
	array<unsigned char>^ salt, 
	int iterations
)
public Rfc2898DeriveBytes (
	byte[] password, 
	byte[] salt, 
	int iterations
)
public function Rfc2898DeriveBytes (
	password : byte[], 
	salt : byte[], 
	iterations : int
)

Parameters

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.

Exception typeCondition

ArgumentException

The specified salt size is smaller than 8 bytes or the iteration count is less than 1.

ArgumentNullException

The password or salt is a null reference (Nothing in Visual Basic).

The salt size must be 8 bytes or larger and the iteration count must be greater than zero. The minimum recommended number of iterations is 1000.

RFC 2898 includes methods for creating a key and initialization vector (IV) from a password and salt. You can use PBKDF2, a password-based key derivation function, to derive keys using a pseudo-random function that allows keys of virtually unlimited length to be generated. The Rfc2898DeriveBytes class can be used to produce a derived key from a base key and other parameters. In a password-based key derivation function, the base key is a password and the other parameters are a salt value and an iteration count.

For more information about PBKDF2, see RFC 2898, "PKCS #5: Password-Based Cryptography Specification Version 2.0", available on the Request for Comments Web site at http://www.rfc-editor.org. See section 5.2, "PBKDF2", for complete details.

Security noteSecurity Note

Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the MSIL Disassembler (Ildasm.exe), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft