SymmetricAlgorithm 对称加密算法

SymmetricAlgorithm

Represents the abstract base class from which all implementations of symmetric algorithms must inherit.

Derived

 

Rijndael Class  不推荐使用,建议使用Aes

Represents the base class from which all implementations of the Rijndael symmetric encryption algorithm must inherit.

 

Remarks

This algorithm supports key lengths of 128, 192, or 256 bits; defaulting to 256 bits. This algorithm supports block sizes of 128, 192, or 256 bits; defaulting to 128 bits (Aes-compatible).

 

The Rijndael class is the predecessor前辈 of the Aes algorithm. You should use the Aes algorithm instead of Rijndael. For more information, see the entry The Differences Between Rijndael and AES in the .NET Security blog.

 

 

 

 

Aes Class

Represents the abstract base class from which all implementations of the Advanced Encryption Standard (AES) must inherit.

Derived

 

 

Key和IV

SymmetricAlgorithm.Key Property

Gets or sets the secret key for the symmetric algorithm.

 

The secret key is used both for encryption and for decryption. For a symmetric algorithm to be successful, the secret key must be known only to the sender and the receiver. The valid key sizes are specified by the particular symmetric algorithm implementation and are listed in the LegalKeySizes property.

If this property is null when it is used, the GenerateKey method is called to create a new random value.

 

SymmetricAlgorithm.IV Property

Gets or sets the initialization vector (IV) for the symmetric algorithm.

The IV property is automatically set to a new random value whenever you create a new instance of one of the SymmetricAlgorithm classes or when you manually call the GenerateIV method. The size of the IV property must be the same as the BlockSize property divided by 8.

The classes that derive from the SymmetricAlgorithm class use a chaining mode called cipher block chaining (CBC), which requires a key and an initialization vector to perform cryptographic transformations on data. To decrypt data that was encrypted using one of the SymmetricAlgorithm classes, you must set the Key property and IV property to the same values that were used for encryption.

For a given secret key k, a simple block cipher that does not use an initialization vector will encrypt the same input block of plain text into the same output block of cipher text. If you have duplicate blocks within your plain text stream, you will have duplicate blocks within your cipher text stream. If unauthorized users know anything about the structure of a block of your plain text, they can use that information to decipher the known cipher text block and possibly recover your key. To combat this problem, information from the previous block is mixed into the process of encrypting the next block. Thus, the output of two identical plain text blocks is different. Because this technique uses the previous block to encrypt the next block, an initialization vector is needed to encrypt the first block of data.

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(939)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2018-04-16 Get-Acl 查看文件权限
2018-04-16 C# 如何调用EventLog
点击右上角即可分享
微信分享提示