Sample code for 30+ languages & platforms
Xbase++

DSA Get Key as XML

Gets the DSA key in XML format.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oDsa
LOCAL nBPublicOnly
LOCAL cXmlStr

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oDsa := CreateObject("Chilkat.Dsa")

//  Generate a new 2048 bit DSA key.
nSuccess := oDsa:GenKey(2048)
IF (nSuccess != 1)
    ? oDsa:LastErrorText
    oDsa:destroy()
    RETURN
ENDIF

//  Get the public key as XML
nBPublicOnly := 1
cXmlStr := oDsa:ToXml(nBPublicOnly)
? cXmlStr

//  Sample output.

//  <DSAKeyValue>
//  	<P>wBYOKu...2eoXw==</P>
//  	<Q>1taJI7...kV2/9c=</Q>
//  	<G>qjfbTi...eB1+g==</G>
//  	<Y>t3tz...NqjsPEg==</Y>
//  </DSAKeyValue>

//  Get the private key as XML.
nBPublicOnly := 0
cXmlStr := oDsa:ToXml(nBPublicOnly)

? cXmlStr

//  Sample output.

//  <DSAKeyValue>
//  	<P>wBYOKu...2eoXw==</P>
//  	<Q>1taJI7...kV2/9c=</Q>
//  	<G>qjfbTi...eB1+g==</G>
//  	<Y>t3tz...NqjsPEg==</Y>
//  	<X>lm9F...XzuVO+qU=</X>
//  </DSAKeyValue>

oDsa:destroy()