(PureBasic) DSA Public Key PEM to DER Conversion
Converts a DSA public key from PEM format to DER.
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 PEM public key.
pemPublicKey.s
pemPublicKey = CkDsa::ckLoadText(dsa,"dsa_pub.pem")
; Import the public key PEM into the DSA object.
success.i = CkDsa::ckFromPublicPem(dsa,pemPublicKey)
If success <> 1
Debug CkDsa::ckLastErrorText(dsa)
CkDsa::ckDispose(dsa)
ProcedureReturn
EndIf
; Write it out as a DER file:
success = CkDsa::ckToPublicDerFile(dsa,"dsa_pub.der")
If success <> 1
Debug CkDsa::ckLastErrorText(dsa)
CkDsa::ckDispose(dsa)
ProcedureReturn
EndIf
Debug "Finished!"
CkDsa::ckDispose(dsa)
ProcedureReturn
EndProcedure
|