iOS/IPhone Programming Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

iOS/IPhone Examples

Bounced Email
Digital Certificates
Digital Signatures
DKIM / DomainKey
DSA
Email Object
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
POP3
RSA
MIME
SMTP
Socket
SOCKS Proxy
Spider
SSH Key
SSH
SFTP
Tar
Upload
XML
XMP
Zip


More Examples...
Amazon S3
NTLM
RSS
Atom
PPMD
Deflate
Bzip2
LZW
Diffie-Hellman
Bz2
Character Encoding
CSV

 

 

 

 

 

 

 

 

(IOS) Extract PKCS7 from MIME and Decrypt

Extracts the base64-encoded PKCS7 body of a MIME message to a file, and then decrypts using Chilkat Crypt2.

Download: Chilkat IOS (IPhone) Objective-C Libraries

NSMutableString *strOutput = [NSMutableString stringWithCapacity:1000];

CkoMime *mime = [[[CkoMime alloc] init] autorelease];

BOOL success;
success = [mime UnlockComponent: @"Anything for 30-day trial"];
if (success == NO) {
    [strOutput appendString: mime.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

success = [mime LoadMimeFile: @"c:/aaworkarea/EmailInBytes.txt"];
if (success != YES) {
    [strOutput appendString: mime.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

success = [mime SaveBody: @"c:/aaworkarea/smime.p7m"];
if (success != YES) {
    [strOutput appendString: mime.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

CkoCrypt2 *crypt = [[[CkoCrypt2 alloc] init] autorelease];

success = [crypt UnlockComponent: @"Anything for 30-day trial"];
if (success == NO) {
    [strOutput appendString: crypt.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

success = [crypt AddPfxSourceFile: @"c:/aaworkarea/my.pfx" password: @"pfxPassword"];
if (success == NO) {
    [strOutput appendString: crypt.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

//  Indicate the public-key (PKCS7) encryption/decryption should be used:
crypt.CryptAlgorithm = @"pki";

NSString *inPath;
inPath = @"c:/aaworkarea/smime.p7m";
NSString *outPath;
outPath = @"c:/aaworkarea/decrypted.dat";

success = [crypt CkDecryptFile: inPath outFile: outPath];
if (success == NO) {
    [strOutput appendString: crypt.LastErrorText];
    [strOutput appendString: @"\n"];
    self.mainTextField.stringValue = strOutput;
    return;
}

[strOutput appendString: @"Success."];
[strOutput appendString: @"\n"];

self.mainTextField.stringValue = strOutput;



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