How to create CngKeyCreationParameters for CngKey object

CngKey : CngKey objects contain properties. Some properties must be added to a key when it is created. Other properties can be added after the key is created.

CngKeyCreationParameters: The CngKeyCreationParameters class enables you to add properties to a key as it is being created.

following code blocks explains how to create CngKeyCreationParameters object

//  Create CngKeyCreationParameters 
CngKeyCreationParameters keyParams = new CngKeyCreationParameters();

// set properties accordingly
keyParams.ExportPolicy =  CngExportPolicies.AllowArchiving;
keyParams.KeyCreationOptions = CngKeyCreationOptions.MachineKey;
keyParams.Provider = new CngProvider("someprovider");

following code block shows how to pass it CngKeyCreationParameters to CngKey object in CngKey.Create Method

CngKey mycngKey =  
       CngKey.Create(new CngAlgorithm(""), "keyName", keyParams);