(PureBasic) Convert DSA Public Key DER to PEM
Converts a DSA public key from DER format to PEM.
IncludeFile "CkDsa.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
dsa.i = CkDsa::ckCreate()
If dsa.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Load a DER public key.
success.i = CkDsa::ckFromPublicDerFile(dsa,"dsa_pub.der")
If success <> 1
Debug CkDsa::ckLastErrorText(dsa)
CkDsa::ckDispose(dsa)
ProcedureReturn
EndIf
pemStr.s
; Save the public key to PEM:
pemStr = CkDsa::ckToPublicPem(dsa)
success = CkDsa::ckSaveText(dsa,pemStr,"dsa_pub.pem")
If success <> 1
Debug CkDsa::ckLastErrorText(dsa)
CkDsa::ckDispose(dsa)
ProcedureReturn
EndIf
Debug "Finished!"
CkDsa::ckDispose(dsa)
ProcedureReturn
EndProcedure
|