Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DSACryptoServiceProvider.ImportParameters Method

Imports the specified DSAParameters.

[Visual Basic]
Overrides Public Sub ImportParameters( _
   ByVal parameters As DSAParameters _
)
[C#]
public override void ImportParameters(
 DSAParameters parameters
);
[C++]
public: void ImportParameters(
 DSAParameters parameters
);
[JScript]
public override function ImportParameters(
   parameters : DSAParameters
);

Parameters

parameters
The parameters for DSA.

Exceptions

Exception Type Condition
CryptographicException The cryptographic service provider (CSP) cannot be acquired.

-or-

The parameters parameter has missing fields.

Example

[Visual Basic] 
Try
    'Create a new DSACryptoServiceProvider object. 
    Dim DSA As New DSACryptoServiceProvider()

    'Export the key information to a DSAParameters object.
    'Pass false to export the public key information or pass
    'true to export public and private key information.
    Dim DSAParams As DSAParameters = DSA.ExportParameters(False)

    'Create another DSACryptoServiceProvider object.
    Dim DSA2 As New DSACryptoServiceProvider()

    'Import the the key information from the other 
    'DSACryptoServiceProvider object.  
    DSA2.ImportParameters(DSAParams)


Catch e As CryptographicException
    'Catch this exception in case the encryption did
    'not succeed.
    Console.WriteLine(e.Message)
End Try

[C#] 
try
{
    //Create a new DSACryptoServiceProvider object. 
    DSACryptoServiceProvider DSA = new DSACryptoServiceProvider();

    //Export the key information to a DSAParameters object.
    //Pass false to export the public key information or pass
    //true to export public and private key information.
    DSAParameters DSAParams = DSA.ExportParameters(false);

    //Create another DSACryptoServiceProvider object.
    DSACryptoServiceProvider DSA2 = new DSACryptoServiceProvider();

    //Import the the key information from the other 
    //DSACryptoServiceProvider object.  
    DSA2.ImportParameters(DSAParams);


}
catch(CryptographicException e)
{
    //Catch this exception in case the encryption did
    //not succeed.
    Console.WriteLine(e.Message);

}

[C++] 
try {
    //Create a new DSACryptoServiceProvider object. 
    DSACryptoServiceProvider* DSA = new DSACryptoServiceProvider();

    //Export the key information to a DSAParameters object.
    //Pass false to export the public key information or pass
    //true to export public and private key information.
    DSAParameters DSAParams = DSA->ExportParameters(false);

    //Create another DSACryptoServiceProvider object.
    DSACryptoServiceProvider* DSA2 = new DSACryptoServiceProvider();

    //Import the the key information from the other 
    //DSACryptoServiceProvider Object*.  
    DSA2->ImportParameters(DSAParams);
} catch (CryptographicException* e) {
    //Catch this exception in case the encryption did
    //not succeed.
    Console::WriteLine(e->Message);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DSACryptoServiceProvider Class | DSACryptoServiceProvider Members | System.Security.Cryptography Namespace | Cryptographic Services

Show:
© 2014 Microsoft. All rights reserved.