Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Delphi ActiveXDelphi DLLVisual FoxProJavaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerShellPythonRubySQL ServerUnicode CUnicode C++Visual Basic 6.0VB.NETVBScript

C Examples

Certificates
Email Object
Encryption
FTP
HTML-to-XML/Text
Gzip
HTTP
IMAP
MHT / HTML Email
POP3
RSA Encryption
MIME
SMTP
Socket/SSL/TLS
SSH Key
SSH
SFTP
Tar Archive
XML
XMP
Zip

More Examples...
Amazon S3
Bounced Email
CSV
Diffie-Hellman
DKIM / DomainKey
NTLM

 

 

 

 

 

 

 

(C) Convert DSA PEM Private Key to DER

Converts a DSA private key from PEM format to DER. The first part of the example will convert an unencrypted PEM to DER, then 2nd part will convert an encrypted PEM to unencrypted DER.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries
#include <C_CkDsa.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkDsa dsa;
    const char * pemPrivateKey;



    dsa = CkDsa_Create();

    success = CkDsa_UnlockComponent(dsa,"Anything for 30-day trial");
    if (success != TRUE) {
        printf("%s\n",CkDsa_lastErrorText(dsa));
        return;
    }

    //  Load a PEM private key.

    pemPrivateKey = CkDsa_loadText(dsa,"dsa_priv.pem");
    //  Import the unencrypted PEM into the DSA object.
    success = CkDsa_FromPem(dsa,pemPrivateKey);
    if (success != TRUE) {
        printf("%s\n",CkDsa_lastErrorText(dsa));
        return;
    }

    //  Write it out as a DER file:
    success = CkDsa_ToDerFile(dsa,"dsa_priv.der");
    if (success != TRUE) {
        printf("%s\n",CkDsa_lastErrorText(dsa));
        return;
    }

    //  Load an encrypted PEM private key.
    pemPrivateKey = CkDsa_loadText(dsa,"dsa_privEncrypted.pem");
    //  Import the encrypted PEM into the DSA object.
    success = CkDsa_FromEncryptedPem(dsa,"myPassword",pemPrivateKey);
    if (success != TRUE) {
        printf("%s\n",CkDsa_lastErrorText(dsa));
        return;
    }

    //  Write it out as an unencrypted DER file:
    success = CkDsa_ToDerFile(dsa,"dsa_priv2.der");
    if (success != TRUE) {
        printf("%s\n",CkDsa_lastErrorText(dsa));
        return;
    }

    printf("Finished!\n");

    CkDsa_Dispose(dsa);

    }

 

© 2000-2014 Chilkat Software, Inc. All Rights Reserved.