Sample code for 30+ languages & platforms
Objective-C

Example: Crypt2.SetDecryptCert method

Demonstrates how to call the SetDecryptCert method.

Chilkat Objective-C Downloads

Objective-C
#import <CkoCert.h>
#import <CkoCrypt2.h>
#import <CkoBinData.h>

BOOL success = NO;

CkoCert *cert = [[CkoCert alloc] init];

success = [cert LoadPfxFile: @"c:/pfx_files/my.pfx" password: @"password"];
if (success != YES) {
    NSLog(@"%@",cert.LastErrorText);
    return;
}

CkoCrypt2 *decrypt = [[CkoCrypt2 alloc] init];
decrypt.CryptAlgorithm = @"pki";

success = [decrypt SetDecryptCert: cert];
if (success != YES) {
    NSLog(@"%@",decrypt.LastErrorText);
    return;
}

CkoBinData *bd = [[CkoBinData alloc] init];
success = [bd LoadFile: @"c:/someDir/pkcs7_encrypted.dat"];

success = [decrypt DecryptBd: bd];
if (success != YES) {
    NSLog(@"%@",decrypt.LastErrorText);
    return;
}

//  bd contains the decrypted content.