RSACng 建構函式

定義

初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class.

多載

RSACng()

使用隨機 2,048 位元金鑰組,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with a random 2,048-bit key pair.

RSACng(Int32)

使用指定大小之隨機產生的金鑰,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with a randomly generated key of the specified size.

RSACng(CngKey)

使用指定的金鑰,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with the specified key.

RSACng()

使用隨機 2,048 位元金鑰組,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with a random 2,048-bit key pair.

public:
 RSACng();
public RSACng ();
Public Sub New ()

備註

這個函式不會立即產生新的公開/私用金鑰組。This constructor does not generate a new public/private keypair immediately. 這個函式會將 KeySize 屬性設定為2048,而當需要索引鍵時,就會使用屬性值來產生一個索引鍵。This constructor sets the KeySize property to 2048 and when a key is needed one is generated using the property value. 如果金鑰是透過 ImportParameters 方法或其他金鑰匯入方法載入,則此函式的索引鍵大小沒有任何意義。If a key is loaded via the ImportParameters method, or other key import method, the key size from this constructor has no meaning.

適用於

RSACng(Int32)

使用指定大小之隨機產生的金鑰,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with a randomly generated key of the specified size.

public:
 RSACng(int keySize);
public RSACng (int keySize);
new System.Security.Cryptography.RSACng : int -> System.Security.Cryptography.RSACng
Public Sub New (keySize As Integer)

參數

keySize
Int32

要產生的金鑰大小 (以位元為單位)。The size of the key to generate in bits.

例外狀況

keySize 無效。keySize is not valid.

備註

有效的金鑰大小範圍從384到16384位,以8為增量。Valid key sizes range from 384 to 16,384 bits, in increments of 8. 建議您將最小大小的2048位用於所有的金鑰。We recommend that a minimum size of 2,048 bits be used for all keys.

這個函式不會立即產生新的公開/私用金鑰組。This constructor does not generate a new public/private keypair immediately. 這個函式 KeySize 會將屬性設定為 keySize ,而且當需要索引鍵時,就會使用屬性值產生一個索引鍵。This constructor sets the KeySize property to keySize and when a key is needed one is generated using the property value. 如果金鑰是透過 ImportParameters 方法或其他金鑰匯入方法載入,則此函式的索引鍵大小沒有任何意義。If a key is loaded via the ImportParameters method, or other key import method, the key size from this constructor has no meaning.

適用於

RSACng(CngKey)

使用指定的金鑰,初始化 RSACng 類別的新執行個體。Initializes a new instance of the RSACng class with the specified key.

public:
 RSACng(System::Security::Cryptography::CngKey ^ key);
public RSACng (System.Security.Cryptography.CngKey key);
new System.Security.Cryptography.RSACng : System.Security.Cryptography.CngKey -> System.Security.Cryptography.RSACng
Public Sub New (key As CngKey)

參數

key
CngKey

RSA 作業所要使用的金鑰。The key to use for RSA operations.

例外狀況

key 不是有效的 RSA 金鑰。key is not a valid RSA key.

keynullkey is null.

備註

CngKey.AlgorithmGroupkey 必須是 CngAlgorithmGroup.RsaThe CngKey.AlgorithmGroup of key must be CngAlgorithmGroup.Rsa.

這個函式會建立金鑰的複本。This constructor creates a copy of the key. 即使 key 已處置,RSA 中這個金鑰組象的複本仍維持運作狀態。Even if key is disposed, the copy of this key object in RSA remains alive.

適用於