Aes和AesManaged有什么区别 [英] What is the difference between Aes and AesManaged

查看:252
本文介绍了Aes和AesManaged有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中发现了两个与 AES 相关的类,并且MSDN提供的示例代码相似,这两个类之间有什么区别?

I found two class in C# related to AES, and example code of them MSDN provides are similar, what is the difference between these two classes?

Aes类

https://msdn.microsoft.com/zh-cn/library/system.security.cryptography.aes(v = vs。 110).aspx

AesManaged Class

https://msdn.microsoft.com /en-us/library/system.security.cryptography.aesmanaged(v=vs.110).aspx

推荐答案

System.Security.Cryptography.Aes 是一个抽象类,仅表示AES-ness概念。 AesManaged AesCryptoServiceProvider AesCng 是AES的具体实现使用托管代码,分别使用Windows CAPI和Windows CNG。 (在.NET Core上,这是一个谎言:AesManaged和AesCryptoServiceProvider都只使用自动魔术隐藏类,该类使用Windows CNG,macOS Security.framework或OpenSSL(如果可用))

System.Security.Cryptography.Aes is an abstract class, representing merely the concept of AES-ness. AesManaged, AesCryptoServiceProvider, and AesCng are concrete implementations of AES in managed code, using Windows CAPI, and using Windows CNG (respectively). (On .NET Core that's a lie: AesManaged and AesCryptoServiceProvider both just use a automagic hidden class which uses Windows CNG, macOS Security.framework, or OpenSSL, as available)

如果不清楚要使用哪个实例,则要通过 Aes.Create()创建一个实例,并且仅使用基本类型。唯一真正的例外是将 AesCng 与命名键一起使用(这种情况非常少见)。

If you're unclear on which one you want, you want to create an instance via Aes.Create() and only use the base type. The only real exception is when using AesCng with a named key (which is very rare).

这篇关于Aes和AesManaged有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆