AsymmetricKeyAlgorithmProvider.OpenAlgorithm | openAlgorithm method

Applies to Windows and Windows Phone

Creates an instance of the AsymmetricKeyAlgorithmProvider class and opens the specified algorithm for use.

Syntax


var asymmetricKeyAlgorithmProvider = Windows.Security.Cryptography.Core.AsymmetricKeyAlgorithmProvider.openAlgorithm(algorithm);

Parameters

algorithm

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Algorithm name.

Return value

Type: AsymmetricKeyAlgorithmProvider

Represents a public key algorithm provider.

Remarks

Use the static properties in the AsymmetricAlgorithmNames class to specify the name of the algorithm to open.

Examples


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

    // Demonstrate use of the AlgorithmName property (not necessary to create a key pair).
    String strAlgName = objAlgProv.AlgorithmName;

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

    // Export the public key to a buffer for use by others.
    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.
    AsymmetricKeyAlgorithmApp.buffKeyPair = keyPair.Export();
}


Requirements

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

AsymmetricKeyAlgorithmProvider

 

 

Show:
© 2014 Microsoft