(Unicode C) DSA Public Key PEM to DER Conversion
Converts a DSA public key from PEM format to DER.
#include <C_CkDsaW.h>
void ChilkatSample(void)
{
HCkDsaW dsa;
const wchar_t *pemPublicKey;
BOOL success;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
dsa = CkDsaW_Create();
// Load a PEM public key.
pemPublicKey = CkDsaW_loadText(dsa,L"dsa_pub.pem");
// Import the public key PEM into the DSA object.
success = CkDsaW_FromPublicPem(dsa,pemPublicKey);
if (success != TRUE) {
wprintf(L"%s\n",CkDsaW_lastErrorText(dsa));
CkDsaW_Dispose(dsa);
return;
}
// Write it out as a DER file:
success = CkDsaW_ToPublicDerFile(dsa,L"dsa_pub.der");
if (success != TRUE) {
wprintf(L"%s\n",CkDsaW_lastErrorText(dsa));
CkDsaW_Dispose(dsa);
return;
}
wprintf(L"Finished!\n");
CkDsaW_Dispose(dsa);
}
|