AsymmetricAlgorithm.LegalKeySizes 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取非对称算法支持的密钥大小。
public:
virtual property cli::array <System::Security::Cryptography::KeySizes ^> ^ LegalKeySizes { cli::array <System::Security::Cryptography::KeySizes ^> ^ get(); };
public virtual System.Security.Cryptography.KeySizes[] LegalKeySizes { get; }
member this.LegalKeySizes : System.Security.Cryptography.KeySizes[]
Public Overridable ReadOnly Property LegalKeySizes As KeySizes()
属性值
KeySizes[]
一个数组,它包含非对称算法支持的密钥大小。
示例
下面的代码示例演示如何调用 LegalKeySizes 属性来检索 MinSize、 MaxSize和 SkipSize 属性。 此代码示例是为 AsymmetricAlgorithm 类提供的一个更大示例的一部分。
array<KeySizes^>^ legalKeySizes = customCryptoAlgorithm->LegalKeySizes;
for (int i = 0; i < legalKeySizes->Length; i++)
{
Console::WriteLine(
"Keysize{0} min, max, step: {1}, {2}, {3}, ", i,
legalKeySizes[i]->MinSize,
legalKeySizes[i]->MaxSize,
legalKeySizes[i]->SkipSize);
}
KeySizes[] legalKeySizes = customCrypto.LegalKeySizes;
if (legalKeySizes.Length > 0)
{
for (int i=0; i < legalKeySizes.Length; i++)
{
Console.Write("Keysize" + i + " min, max, step: ");
Console.Write(legalKeySizes[i].MinSize + ", ");
Console.Write(legalKeySizes[i].MaxSize + ", ");
Console.WriteLine(legalKeySizes[i].SkipSize + ", ");
}
}
Dim legalKeySizes() As KeySizes = customCrypto.LegalKeySizes
If (legalKeySizes.Length > 0) Then
For i As Integer = 0 To legalKeySizes.Length - 1 Step 1
Write("Keysize" + i.ToString() + " min, max, step: ")
Write(legalKeySizes(i).MinSize.ToString() + ", ")
Write(legalKeySizes(i).MaxSize.ToString() + ", ")
Write(legalKeySizes(i).SkipSize.ToString() + ", ")
WriteLine("")
Next
End If
注解
非对称算法仅支持与此数组中的条目匹配的密钥大小。