SymmetricAlgorithm.GenerateKey SymmetricAlgorithm.GenerateKey SymmetricAlgorithm.GenerateKey SymmetricAlgorithm.GenerateKey Method

定义

当在派生类中重写时,生成用于该算法的随机密钥 (Key)。When overridden in a derived class, generates a random key (Key) to use for the algorithm.

public:
 abstract void GenerateKey();
public abstract void GenerateKey ();
abstract member GenerateKey : unit -> unit
Public MustOverride Sub GenerateKey ()

注解

通常,没有理由使用此方法,因为CreateEncryptor()CreateEncryptor(null, null)会自动生成初始化向量和键。In general, there is no reason to use this method, because CreateEncryptor() or CreateEncryptor(null, null) automatically generates both an initialization vector and a key. 但是,你可能想要使用GenerateKey方法将对称算法实例与其他密钥一起使用。However, you may want to use the GenerateKey method to reuse a symmetric algorithm instance with a different key.

适用于

另请参阅