PasswordDeriveBytes.CryptDeriveKey(String, String, Int32, Byte[]) メソッド

定義

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()

パラメーター

algname
String

キーを派生させる対象となるアルゴリズム名。

alghashname
String

キーを派生させるために使用するハッシュ アルゴリズム名。

keySize
Int32

派生させるキーのサイズ (ビット単位)。

rgbIV
Byte[]

キーを派生させるために使用する初期化ベクター (IV: Initialization Vector)。

戻り値

Byte[]

派生させたキー。

属性

例外

keySize パラメーターが正しくありません。

  • または - 暗号化サービス プロバイダー (CSP) を取得できません。

  • または - algname パラメーターが有効なアルゴリズム名ではありません。

  • または - alghashname パラメーターが有効なハッシュ アルゴリズム名ではありません。

このコード例は、PasswordDeriveBytes クラスのために提供されている大規模な例の一部です。

// 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)

注釈

この関数は、Crypto API 関数 CryptDeriveKey() のラッパーであり、Crypto API を使用してアプリケーションとの相互運用性を提供することを目的としています。

パラメーターが keySize 0 ビットに設定されている場合は、指定したアルゴリズムの既定のキー サイズが使用されます。

適用対象

こちらもご覧ください