Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 1.52 KB

CryptGenKey.md

File metadata and controls

64 lines (44 loc) · 1.52 KB

Home

Function name : CryptGenKey

Group: Cryptography Reference - Library: advapi32


Generates a random cryptographic session key or a public/private key pair. A handle to the key or key pair is returned in phKey. This handle can then be used as needed with any CryptoAPI function that requires a key handle.


Code examples:

CryptoAPI: Collection of Providers class
Generating random cryptographic keys

Declaration:

BOOL WINAPI CryptGenKey(
	HCRYPTPROV hProv,
	ALG_ID Algid,
	DWORD dwFlags,
	HCRYPTKEY* phKey
);  

FoxPro declaration:

DECLARE INTEGER CryptGenKey IN advapi32;
	INTEGER   hProv,;
	INTEGER   Algid,;
	INTEGER   dwFlags,;
	INTEGER @ phKey
  

Parameters:

hProv [in] Handle to a cryptographic service provider (CSP) created by a call to CryptAcquireContext.

Algid [in] A ALG_ID structure that identifies the algorithm for which the key is to be generated.

dwFlags [in] Specifies the type of key generated.

phKey [out] Address to which the function copies the handle of the newly generated key.


Return value:

If the function succeeds, the return value is nonzero (TRUE).


Comments:

When you have finished using the key, delete the handle to the key by calling the CryptDestroyKey function.