KeySize | keySize property
Collapse the table of content
Expand the table of content

CryptographicKey.KeySize | keySize property

Gets the size, in bits, of the key.

Syntax


var keySize = cryptographicKey.keySize;

Property value

Type: Number [JavaScript] | System.UInt32 [.NET] | uint32 [C++]

Integer that contains the number of bits in the key.

Examples


public IBuffer SampleCreateAsymmetricKeyPair(
    String strAsymmetricAlgName,
    UInt32 keyLength)
{
    // Open the algorithm provider for the specified asymmetric algorithm.
    AsymmetricKeyAlgorithmProvider objAlgProv = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(strAsymmetricAlgName);

    // Create an asymmetric key pair.
    CryptographicKey keyPair = objAlgProv.CreateKeyPair(keyLength);

    // Export the public key to a buffer for use by others.
    IBuffer buffPublicKey = keyPair.ExportPublicKey();

    // You should keep your private key (embedded in the key pair) secure. For  
    // the purposes of this example, however, we're just copying it into a
    // static class variable for later use during decryption.
    CryptographicKeyApp.buffKeyPair = keyPair.Export();

    // Retrieve the size of the key pair.
    UInt32 lengthKeyPair = keyPair.KeySize;

    // Return the public key.
    return buffPublicKey;
}


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Security.Cryptography.Core
Windows::Security::Cryptography::Core [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography.Core
Windows::Security::Cryptography::Core [C++]

Metadata

Windows.winmd

See also

CryptographicKey

 

 

Show:
© 2016 Microsoft