This documentation is archived and is not being maintained.

PasswordDeriveBytes.CryptDeriveKey Method

Derives a cryptographic key from the PasswordDeriveBytes object.

[Visual Basic]
Public Function CryptDeriveKey( _
   ByVal algname As String, _
   ByVal alghashname As String, _
   ByVal keySize As Integer, _
   ByVal rgbIV() As Byte _
) As Byte()
public byte[] CryptDeriveKey(
 string algname,
 string alghashname,
 int keySize,
 byte[] rgbIV
public: unsigned char CryptDeriveKey(
 String* algname,
 String* alghashname,
 int keySize,
 unsigned char rgbIV __gc[]
)  __gc[];
public function CryptDeriveKey(
   algname : String,
 alghashname : String,
 keySize : int,
 rgbIV : Byte[]
) : Byte[];


The algorithm name for which to derive the key.
The hash algorithm name to use to derive the key.
The size of the key to derive.
The initialization vector (IV) to use to derive the key.

Return Value

The derived key.


Exception Type Condition
CryptographicException The keySize parameter is greater than 128.


The cryptographic service provider (CSP) cannot be acquired.


The algname parameter is not a valid algorithm name.


The alghashname parameter is not a valid hash algorithm name.


This function is a wrapper for the Crypto API function CryptDeriveKey(), and is intended to offer interoperability with applications using the Crypto API.

If the keySize parameter is set to 0, the default key size for the specified algorithm is used.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PasswordDeriveBytes Class | PasswordDeriveBytes Members | System.Security.Cryptography Namespace | Cryptographic Services