SymmetricAlgorithm.IV SymmetricAlgorithm.IV SymmetricAlgorithm.IV SymmetricAlgorithm.IV Property

定义

获取或设置对称算法的初始化向量 (IV)。Gets or sets the initialization vector (IV) for the symmetric algorithm.

public:
 virtual property cli::array <System::Byte> ^ IV { cli::array <System::Byte> ^ get(); void set(cli::array <System::Byte> ^ value); };
public virtual byte[] IV { get; set; }
member this.IV : byte[] with get, set
Public Overridable Property IV As Byte()

属性值

Byte[]

初始化向量。The initialization vector.

异常

试图将初始化向量设置为 nullAn attempt was made to set the initialization vector to null.

试图将初始化向量设置为无效大小。An attempt was made to set the initialization vector to an invalid size.

注解

IV属性自动设置为新的随机值,只要创建的其中一个新实例,就SymmetricAlgorithm类或当您手动调用GenerateIV方法。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. 大小IV属性必须与相同BlockSize属性除以 8。The size of the IV property must be the same as the BlockSize property divided by 8.

派生的类SymmetricAlgorithm类使用称为密码块链 (CBC) 的链接模式需要一个密钥和初始化向量对数据执行加密转换。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. 使用其中一个加密的数据进行解密SymmetricAlgorithm类,必须设置Key属性和IV为已加密所用的相同值的属性。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.

对于给定的密钥k,不使用初始化向量的简单块密码将到相同的密码文本的输出块加密的纯文本相同的输入的块。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.

适用于

另请参阅