Sample code for 30+ languages & platforms
Objective-C

RSA Import Private Key

See more RSA Examples

Shows how to select/import a private key for RSA signing or decryption.

Chilkat Objective-C Downloads

Objective-C
#import <CkoPrivateKey.h>
#import <NSString.h>
#import <CkoRsa.h>

BOOL success = NO;

CkoPrivateKey *privKey = [[CkoPrivateKey alloc] init];
NSString *password = @"secret";
//  In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success = [privKey LoadAnyFormatFile: @"rsaKeys/myTestRsaPrivate.pem" password: password];
if (success == NO) {
    NSLog(@"%@",privKey.LastErrorText);
    return;
}

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

//  Tell the RSA object to use the private key (i.e. import the private key)
[rsa UsePrivateKey: privKey];