Sample code for 30+ languages & platforms
Tcl

DSA Get Key as XML

Gets the DSA key in XML format.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set dsa [new_CkDsa]

# Generate a new 2048 bit DSA key.
set success [CkDsa_GenKey $dsa 2048]
if {$success != 1} then {
    puts [CkDsa_lastErrorText $dsa]
    delete_CkDsa $dsa
    exit
}

# Get the public key as XML
set bPublicOnly 1
set xmlStr [CkDsa_toXml $dsa $bPublicOnly]
puts "$xmlStr"

# 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.
set bPublicOnly 0
set xmlStr [CkDsa_toXml $dsa $bPublicOnly]

puts "$xmlStr"

# 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>

delete_CkDsa $dsa