CryptoConfig.CreateFromName CryptoConfig.CreateFromName CryptoConfig.CreateFromName CryptoConfig.CreateFromName Method

定义

创建指定的加密对象的新实例。Creates a new instance of the specified cryptographic object.

重载

CreateFromName(String) CreateFromName(String) CreateFromName(String) CreateFromName(String)

创建指定的加密对象的新实例。Creates a new instance of the specified cryptographic object.

CreateFromName(String, Object[]) CreateFromName(String, Object[]) CreateFromName(String, Object[]) CreateFromName(String, Object[])

用指定的参数创建指定的加密对象的新实例。Creates a new instance of the specified cryptographic object with the specified arguments.

CreateFromName(String) CreateFromName(String) CreateFromName(String) 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

参数

name
String String String String

将创建其实例的加密对象的简单名称。The simple name of the cryptographic object of which to create an instance.

返回

指定的加密对象的新实例。A new instance of the specified cryptographic object.

异常

name 参数描述的算法在使用中已启用联邦信息处理标准 (FIPS) 模式,但与 FIPS 不兼容。The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

示例

下面的代码示例演示如何调用CreateFromName方法来创建新的 SHA1 提供程序。The following code example demonstrates how to call the CreateFromName method to create a new SHA1 provider. 此代码示例是为CryptoConfig类提供的更大示例的一部分。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)

注解

有关此类识别的简单名称的列表,请参见CryptoConfigFor a list of simple names recognized by this class, see CryptoConfig.

另请参阅

CreateFromName(String, Object[]) CreateFromName(String, Object[]) CreateFromName(String, Object[]) 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

参数

name
String String String 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.

返回

指定的加密对象的新实例。A new instance of the specified cryptographic object.

异常

name 参数描述的算法在使用中已启用联邦信息处理标准 (FIPS) 模式,但与 FIPS 不兼容。The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

示例

下面的代码示例演示如何调用CreateFromName方法以初始化TestContainer访问密钥容器的新 RSA 提供程序实例。The following code example demonstrates how to call the CreateFromName method to initialize a new RSA provider instance accessing the TestContainer key container. 此代码示例是为CryptoConfig类提供的更大示例的一部分。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)

注解

有关此类识别的简单名称的列表,请参见CryptoConfigFor a list of simple names recognized by this class, see CryptoConfig.

另请参阅

适用于