Sample code for 30+ languages & platforms
Objective-C

Obfuscate String

Demonstrates how to obfuscate and unobfuscate a string.

Chilkat Objective-C Downloads

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

BOOL success = NO;

CkoStringBuilder *sb = [[CkoStringBuilder alloc] init];

NSString *s = @"Hello World!";

[sb Append: s];
NSLog(@"%@",[sb GetAsString]);

//  Output is "Hello World!";

//  Obfuscate the string.
//  This is NOT encryption.  It's just a simple obfuscation.
[sb Obfuscate];
NSLog(@"%@",[sb GetAsString]);

//  Output is 2GsgGhbSQVyG8Vb9

//  -------------------------
//  Unobfuscate.
CkoStringBuilder *sb2 = [[CkoStringBuilder alloc] init];
NSString *s2 = @"2GsgGhbSQVyG8Vb9";
[sb2 Append: s2];
[sb2 Unobfuscate];

NSLog(@"%@",[sb2 GetAsString]);

//  Output is "Hello World!";