PasswordDeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) Metoda

Definice

Odvozuje kryptografický klíč z objektu PasswordDeriveBytes .

public:
 cli::array <System::Byte> ^ CryptDeriveKey(System::String ^ algname, System::String ^ alghashname, int keySize, cli::array <System::Byte> ^ rgbIV);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public byte[] CryptDeriveKey (string? algname, string? alghashname, int keySize, byte[] rgbIV);
public byte[] CryptDeriveKey (string algname, string alghashname, int keySize, byte[] rgbIV);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.CryptDeriveKey : string * string * int * byte[] -> byte[]
member this.CryptDeriveKey : string * string * int * byte[] -> byte[]
Public Function CryptDeriveKey (algname As String, alghashname As String, keySize As Integer, rgbIV As Byte()) As Byte()

Parametry

algname
String

Název algoritmu, pro který má klíč odvodit.

alghashname
String

Název algoritmu hash, který se má použít k odvození klíče.

keySize
Int32

Velikost klíče v bitech, která se má odvodit.

rgbIV
Byte[]

Inicializační vektor (IV), který se má použít k odvození klíče.

Návraty

Byte[]

Odvozený klíč.

Atributy

Výjimky

Parametr keySize je nesprávný.

-nebo- Zprostředkovatel kryptografických služeb (CSP) nelze získat.

-nebo- Parametr algname není platný název algoritmu.

-nebo- Parametr alghashname není platný název algoritmu hash.

Příklady

Tento příklad kódu je součástí většího příkladu zadaného PasswordDeriveBytes pro třídu.

// Create the key and set it to the Key property
// of the TripleDESCryptoServiceProvider object.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
 cryptoDESProvider->Key = passwordDeriveBytes->CryptDeriveKey
     ("TripleDES", "SHA1", 192, cryptoDESProvider->IV);

// Create the key and set it to the Key property
// of the TripleDESCryptoServiceProvider object.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV);

' Create the key and set it to the Key property
' of the TripleDESCryptoServiceProvider object.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
tdes.Key = pdb.CryptDeriveKey("TripleDES", "SHA1", 192, tdes.IV)

Poznámky

Tato funkce je obálka pro funkci kryptografického rozhraní API CryptDeriveKey() a má nabízet interoperabilitu s aplikacemi používajícími rozhraní Crypto API.

keySize Pokud je parametr nastavený na 0 bitů, použije se výchozí velikost klíče zadaného algoritmu.

Platí pro

Viz také