Sample code for 30+ languages & platforms
C

RSA Import Public Key

See more RSA Examples

Shows how to select/import a public key for RSA encryption or signature verification.

Chilkat C Downloads

C
#include <C_CkPublicKey.h>
#include <C_CkRsa.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkPublicKey pubKey;
    HCkRsa rsa;

    success = FALSE;

    pubKey = CkPublicKey_Create();
    //  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
    success = CkPublicKey_LoadFromFile(pubKey,"rsaKeys/myTestRsaPublic.pem");
    if (success == FALSE) {
        printf("%s\n",CkPublicKey_lastErrorText(pubKey));
        CkPublicKey_Dispose(pubKey);
        return;
    }

    rsa = CkRsa_Create();

    //  Tell RSA to use the public key.
    CkRsa_UsePublicKey(rsa,pubKey);


    CkPublicKey_Dispose(pubKey);
    CkRsa_Dispose(rsa);

    }