CryptoConfig.CreateFromName Method

Definition

Creates a new instance of the specified cryptographic object.

Overloads

CreateFromName(String)

Creates a new instance of the specified cryptographic object.

CreateFromName(String, Object[])

Creates a new instance of the specified cryptographic object with the specified arguments.

CreateFromName(String)

Creates a new instance of the specified cryptographic object.

public:
 static System::Object ^ CreateFromName(System::String ^ name);
public static object CreateFromName (string name);
static member CreateFromName : string -> obj
Public Shared Function CreateFromName (name As String) As Object

Parameters

name
String

The simple name of the cryptographic object of which to create an instance.

Returns

A new instance of the specified cryptographic object.

Exceptions

The name parameter is null.

The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

Examples

The following code example demonstrates how to call the CreateFromName method to create a new SHA1 provider. This code example is part of a larger example provided for the CryptoConfig class.

SHA1CryptoServiceProvider^ SHA1alg =
   dynamic_cast<SHA1CryptoServiceProvider^>(
      CryptoConfig::CreateFromName( L"SHA1" ));
SHA1CryptoServiceProvider SHA1alg = 
    (SHA1CryptoServiceProvider)CryptoConfig.CreateFromName("SHA1");
Dim SHA1alg As SHA1CryptoServiceProvider
SHA1alg = CType( _
    cryptoConfig.CreateFromName("SHA1"), SHA1CryptoServiceProvider)

Remarks

For a list of simple names recognized by this class, see CryptoConfig.

See also

CreateFromName(String, Object[])

Creates a new instance of the specified cryptographic object with the specified arguments.

public:
 static System::Object ^ CreateFromName(System::String ^ name, cli::array <System::Object ^> ^ args);
public static object CreateFromName (string name, object[] args);
static member CreateFromName : string * obj[] -> obj
Public Shared Function CreateFromName (name As String, args As Object()) As Object

Parameters

name
String

The simple name of the cryptographic object of which to create an instance.

args
Object[]

The arguments used to create the specified cryptographic object.

Returns

A new instance of the specified cryptographic object.

Exceptions

The name parameter is null.

The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

Examples

The following code example demonstrates how to call the CreateFromName method to initialize a new RSA provider instance accessing the TestContainer key container. This code example is part of a larger example provided for the CryptoConfig class.

CspParameters^ parameters = gcnew CspParameters;
parameters->KeyContainerName = L"TestContainer";
array<Object^>^argsArray = gcnew array<Object^>(1){
   parameters
};

// Instantiate the RSA provider instance accessing the TestContainer
// key container.
RSACryptoServiceProvider^ rsaProvider =
   static_cast<RSACryptoServiceProvider^>(
      CryptoConfig::CreateFromName( L"RSA", argsArray ));
CspParameters parameters = new CspParameters();
parameters.KeyContainerName = "TestContainer";
Object[] argsArray = new Object[] {parameters};

// Instantiate the RSA provider instance accessing the TestContainer
// key container.
RSACryptoServiceProvider rsaProvider = (RSACryptoServiceProvider) 
    CryptoConfig.CreateFromName("RSA",argsArray);
Dim parameters As New CspParameters
parameters.KeyContainerName = "TestContainer"
Dim argsArray() = New Object() {parameters}

' Instantiate the RSA provider instance accessing the key container
'  TestContainer.
Dim rsaProvider As New RSACryptoServiceProvider
rsaProvider = CType(cryptoConfig.CreateFromName( _
    "RSA", argsArray), _
    RSACryptoServiceProvider)

Remarks

For a list of simple names recognized by this class, see CryptoConfig.

See also

Applies to