Share via


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ý se má klíč odvodit.

alghashname
String

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

keySize
Int32

Velikost klíče (v bitech) k odvození.

rgbIV
Byte[]

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

Návraty

Byte[]

Odvozený klíč.

Atributy

Výjimky

Parametr keySize je nesprávný.

-nebo-

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

-nebo-

Parametr algname není platný název algoritmu.

-nebo-

Parametr alghashname není platný název hashovacího algoritmu.

Příklady

Tento příklad kódu je součástí většího příkladu 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álkou pro funkci kryptografického rozhraní API CryptDeriveKey() a je určená k tomu, aby nabízela interoperabilitu s aplikacemi využívajícími rozhraní Crypto API.

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

Platí pro

Viz také