AES 加密和 C#

时间:2023-03-28
本文介绍了AES 加密和 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

根据我的阅读,我不确定 AES 是一种可以使用不同长度密钥的单一标准化算法,还是一系列类似算法?我的意思是,如果我发现任何 2 个采用 128 位密钥的 AES 实现,我是否应该确信它们会以相同的方式工作(排除错误)?

From my reading I am not sure if AES is a single, standardized algorithm that can work with different length keys, or a family of similar algorithms? What I mean is if I find any 2 AES implementations taking a 128-bit key, should I be confident they will work identically (barring bugs)?

特别是在.Net/C#中,我很困惑为什么抽象基类System.Security.Cryptography.Aes有两种实现:System.Security.Cryptography.AesCryptoServiceProvider &System.Security.Cryptography.AesManaged.

Specifically in .Net/C#, I was confused why there are two implementations of abstract base class System.Security.Cryptography.Aes: System.Security.Cryptography.AesCryptoServiceProvider & System.Security.Cryptography.AesManaged.

然后似乎 AES 和 Rijndael 之间存在区别/重叠,.NET 有 RijndaelRijndaelManaged 类,以及 RijndaelManagedTransform

Then there seems to be distinction/overlap between AES and Rijndael, .NET has Rijndael and RijndaelManaged classes, as well as RijndaelManagedTransform

所有这些之间有什么区别?我注意到 AES 类似乎只存在于 .NET 3.5 之后,而 Rijndael 从 1.0 开始就存在

What's the differences between all of these? I notice AES classes seem to only exist since .NET 3.5 whereas Rijndael has been around since 1.0

对不起,如果这些是愚蠢的问题,我是加密的新手,而不是安全散列函数.

Sorry if these are dumb questions, I'm new to crypto other than secure hashing functions.

推荐答案

AES,高级加密标准,定义在 FIPS PUB 197 三种对称分组密码:AES-128、AES-192 和 AES-256.所有三种算法都由 Rijndael 算法的特定参数选择定义.

AES, the Advanced Encryption Standard, defines in FIPS PUB 197 three symmetric block-ciphers: AES-128, AES-192 and AES-256. All three algorithms are defined by specific parameter-choices for the Rijndael algorithm.

AES-128-encryption 是一个函数(密钥、数据)->(加密).Rijndael-encryption 是一个函数 (key, data, block-size, key-size) -> (encryption).

AES-128-encryption is a function (key, data) -> (encryption). Rijndael-encryption is a function (key, data, block-size, key-size) -> (encryption).

AesCryptoServiceProvider 使用底层 Windows CryptoAPI 来执行加密.AesManaged 在纯托管代码中执行加密.RijndaelManaged 支持所有参数选择(在纯托管代码中也是如此).

AesCryptoServiceProvider uses the underlying Windows CryptoAPI to perform the encryption. AesManaged performs the encryption in pure managed code. RijndaelManaged supports the full range of parameter-choices (also in pure managed code).

使用 AesCryptoServiceProvider 的优势包括提高速度的潜力以及 CryptoAPI 已通过 FIPS 认证(在某些版本的 Windows 上).

Advantages to using AesCryptoServiceProvider include potential for higher speed and the fact that CryptoAPI is FIPS certified (on certain versions of Windows).

AesManaged 的优点包括可移植性(并非所有版本的 Windows 都支持 AesCryptoServiceProvider).

Advantages to AesManaged include portability (AesCryptoServiceProvider is not supported on all versions of Windows).

RijndaelManaged 的唯一优势是它在 .NET 框架的早期版本中受支持 - 我从未见过有人使用非 AES 参数选择.

The only advantage to RijndaelManaged is that it is supported in early versions of the .NET framework - I haven't ever seen anyone use the non-AES parameter-choices.

这篇关于AES 加密和 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:C# 中的非对称加密示例 下一篇:点网中的Android应用内计费验证收据(C#)

相关文章