Skip to main content
 首页 » 编程设计

c#之'DES' 类和 'DESCryptoServiceProvider' 类有什么区别

2024年02月24日28hnrainll

我所能确定的是,其中一个是所有“DES”算法的 BC,后者是 DES 算法的加密服务提供程序实现的包装器。

我问的原因是我正在复习 .Net Security,而 MS 官方培训书只是指 DES 类,而另一本官方 MS 书指的是 DESCrypto 类。这两者有什么区别?你什么时候使用它们中的任何一个?就 70-536 考试而言,我需要知道什么。

就 70-536 考试而言,我是从教育 P.O.V 提出问题的。

更新:

有人想阐明 IV 属性吗?

请您参考如下方法:

是的,DES类是一个抽象基类,DESCryptoServiceProvider是它的具体实现。继承链有点无聊,它是唯一的。

大多数密码学类(class)都遵循这种模式。是documented如下:

The .NET Framework security system implements an extensible pattern of derived class inheritance. The hierarchy is as follows:

  • Algorithm type class, such as SymmetricAlgorithm or HashAlgorithm. This level is abstract.
  • Algorithm class that inherits from an algorithm type class; for example, RC2 or SHA1. This level is abstract.
  • Implementation of an algorithm class that inherits from an algorithm class; for example, RC2CryptoServiceProvider or SHA1Managed. This level is fully implemented.

Using this pattern of derived classes, it is easy to add a new algorithm or a new implementation of an existing algorithm. For example, to create a new public-key algorithm, you would inherit from the AsymmetricAlgorithm class. To create a new implementation of a specific algorithm, you would create a nonabstract derived class of that algorithm.

不太确定有人实际添加新公钥算法的频率。