Using .NET System.Security.Cryptography.CspParameters from ASP

The CspParameters class represents parameters that you can pass to managed cryptography classes that internally use Microsoft Cryptographic Service Providers (CSPs) from the unmanaged Microsoft Cryptography API (CAPI). Classes with names ending in "CryptoServiceProvider" are managed code wrappers for the corresponding CSP.

Use the CspParameters class to do the following:

  1. Specify a particular CSP by passing the provider type to the ProviderType or ProviderName property. You can also specify a CSP using an overload of the constructor.
  2. Create a key container where you can store cryptographic keys. Key containers provide the most secure way to persist cryptographic keys and keep them secret from malicious third parties. For more information about creating key containers, see How to: Store Asymmetric Keys in a Key Container.
  3. Specify whether to create an asymmetric signature key or an asymmetric exchange key using the KeyNumber property.

More info about System.Security.Cryptography.CspParameters class at MSDN Library.

Output


Sources

/dot-NET/System.Security.Cryptography.CspParameters.asp

<%@ language="VBScript" %>
<!--#include virtual="/lib/unit-tests.asp"-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="/lib/unit-tests.css" rel="stylesheet" type="text/css" />
<h1>Using .NET System.Security.Cryptography.CspParameters from ASP</h1>
<p>
	The CspParameters class represents parameters that you can pass to managed cryptography classes that internally use Microsoft Cryptographic Service Providers (CSPs) from the unmanaged Microsoft Cryptography API (CAPI). Classes with names ending in "CryptoServiceProvider" are managed code wrappers for the corresponding CSP.
</p>
<p>
	Use the CspParameters class to do the following:
	<ol>
		<li>Specify a particular CSP by passing the provider type to the ProviderType or ProviderName property. You can also specify a CSP using an overload of the constructor.</li>
		<li>Create a key container where you can store cryptographic keys. Key containers provide the most secure way to persist cryptographic keys and keep them secret from malicious third parties. For more information about creating key containers, see How to: Store Asymmetric Keys in a Key Container.</li>
		<li>Specify whether to create an asymmetric signature key or an asymmetric exchange key using the KeyNumber property.</li>
	</ol>
</p>
<p>
	More info about System.Security.Cryptography.CspParameters class at <a href="https://msdn.microsoft.com/en-us/library/System.Security.Cryptography.CspParameters.aspx">MSDN Library</a>.
</p>
<h2>Output</h2>
<div class="code"><pre><%
 
' PS> new-object System.Security.Cryptography.CspParameters | gm | format-list > System.Security.Cryptography.CspParameters.txt
 
'System.Security.Cryptography.CspParameters
 
'	System.Boolean Equals(Object obj)
 
'	System.Int32 GetHashCode()
 
'	System.Type GetType()
 
'	System.Security.AccessControl.CryptoKeySecurity get_CryptoKeySecurity()
 
'	System.Security.Cryptography.CspProviderFlags get_Flags()
 
'	System.Security.SecureString get_KeyPassword()
 
'	System.IntPtr get_ParentWindowHandle()
 
'	System.Void set_CryptoKeySecurity(CryptoKeySecurity value)
 
'	System.Void set_Flags(CspProviderFlags value)
 
'	System.Void set_KeyPassword(SecureString value)
 
'	System.Void set_ParentWindowHandle(IntPtr value)
 
'	System.String ToString()
 
'	System.Security.AccessControl.CryptoKeySecurity CryptoKeySecurity {get;set;}
 
'	System.Security.Cryptography.CspProviderFlags Flags {get;set;}
 
'	System.String KeyContainerName {get;set;}
 
'	System.Int32 KeyNumber {get;set;}
 
'	System.Security.SecureString KeyPassword {get;set;}
 
'	System.IntPtr ParentWindowHandle {get;set;}
 
'	System.String ProviderName {get;set;}
 
'	System.Int32 ProviderType {get;set;}
 
with Server.createObject("System.Security.Cryptography.CspParameters")
	.KeyContainerName = "MyContainer"
	.ProviderName = "Microsoft.NET"
	.Flags = 1' 1 -> UseMachineKeyStore, 2 -> UseDefaultKeyContainer (default)
end with
 
%></pre></div>
<hr />
<h2>Sources</h2>
<h3><%= Request.ServerVariables("SCRIPT_NAME") %></h3>
<div class="code"><%= geshify( loadTextFile( Server.mapPath( Request.ServerVariables("SCRIPT_NAME") ) ), "asp" ) %></div>