Επεξεργασία

Κοινή χρήση μέσω


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)

Source:
CryptoConfig.cs
Source:
CryptoConfig.cs
Source:
CryptoConfig.cs

Creates a new instance of the specified cryptographic object.

public:
 static System::Object ^ CreateFromName(System::String ^ name);
public static object? CreateFromName (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" ));
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
SHA1CryptoServiceProvider SHA1alg = 
    (SHA1CryptoServiceProvider)CryptoConfig.CreateFromName("SHA1");
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
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

Applies to

CreateFromName(String, Object[])

Source:
CryptoConfig.cs
Source:
CryptoConfig.cs
Source:
CryptoConfig.cs

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 System::Object ^ CreateFromName(System::String ^ name, cli::array <System::Object ^> ^ args);
public static object? CreateFromName (string name, params object?[]? args);
public static object CreateFromName (string name, params object[] args);
public static object CreateFromName (string name, object[] args);
static member CreateFromName : string * obj[] -> obj
Public Shared Function CreateFromName (name As String, ParamArray args As Object()) As Object
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.
RSA rsa = (RSA)
    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 rsa As RSA = RSA.Create()
rsa = CType(cryptoConfig.CreateFromName( _
    "RSA", argsArray), _
    RSA)

Remarks

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

See also

Applies to