<nameEntry> 元素

将类名映射到易记算法名称,该名称允许一个类具有许多友好名称。

<配置><mscorlib><cryptographySettings><cryptoNameMapping><nameEntry>

Syntax

<nameEntry name="friendly name" Class="class name" />

特性和元素

下列各节描述了特性、子元素和父元素。

特性

Attribute Description
name 必需属性。

指定加密类实现的算法的友好名称。
class 必需属性。

指定 cryptoClass> 元素中<属性的值name

子元素

没有。

父元素

元素 Description
configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。
system.web 指定 ASP.NET 配置节的根元素。

注解

name 属性可以是命名空间中找到 System.Security.Cryptography 的一个抽象类的名称。 在抽象加密类上调用 Create 该方法时,抽象类名称将 CreateFromName 传递给该方法。 CreateFromName 返回属性指示 class 的类型实例。 name如果该属性是短名称(如 RSA),则可以在调用CreateFromName该方法时使用该名称。

Example

以下示例演示如何使用 <nameEntry> 元素引用加密类和配置运行时。 然后,可以将字符串“RSA”传递给 CryptoConfig.CreateFromName 该方法,并使用 Create 该方法返回对象 MyCryptoRSAClass

<configuration>
   <mscorlib>
      <cryptographySettings>
         <cryptoNameMapping>
            <cryptoClasses>
               <cryptoClass   MyCryptoRSA="MyCryptoRSAClass, MyAssembly
                  Culture=neutral, PublicKeyToken=a5d015c7d5a0b012,
                  Version=1.0.0.0"/>
            </cryptoClasses>
            <nameEntry name="RSA" class="MyCryptoRSA"/>
            <nameEntry name="System.Security.Cryptography.AsymmetricAlgorithm"
                       class="MyCryptoRSA"/>
         </cryptoNameMapping>
      </cryptographySettings>
   </mscorlib>
</configuration>

另请参阅