Sample code for 30+ languages & platforms
Objective-C

RSA Import Public Key

See more RSA Examples

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

Chilkat Objective-C Downloads

Objective-C
#import <CkoPublicKey.h>
#import <CkoRsa.h>

BOOL success = NO;

CkoPublicKey *pubKey = [[CkoPublicKey alloc] init];
//  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success = [pubKey LoadFromFile: @"rsaKeys/myTestRsaPublic.pem"];
if (success == NO) {
    NSLog(@"%@",pubKey.LastErrorText);
    return;
}

CkoRsa *rsa = [[CkoRsa alloc] init];

//  Tell RSA to use the public key.
[rsa UsePublicKey: pubKey];