Sample code for 30+ languages & platforms
Objective-C

Base64 Encode/Decode a String

See more Encryption Examples

_LANGUAGE_ example to base-64 encode and decode a string.

Chilkat Objective-C Downloads

Objective-C
#import <CkoBinData.h>
#import <NSString.h>

BOOL success = NO;

CkoBinData *bd = [[CkoBinData alloc] init];

NSString *s = @"A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump";

success = [bd AppendString: s charset: @"utf-8"];

NSString *strBase64 = [bd GetEncoded: @"base64"];
NSLog(@"%@",strBase64);

//  To decode:
CkoBinData *bd2 = [[CkoBinData alloc] init];
[bd2 AppendEncoded: strBase64 encoding: @"base64"];

NSString *decoded = [bd2 GetString: @"utf-8"];
NSLog(@"%@",decoded);