Base64 Encoded/Decoding a NSString Object
Encoding
NSString *plainString = @”iOS Developer Tips encoded in Base64”;
NSData *nsdata = [plainString dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0];
// Print the Base64 encoded string
NSLog(@”Encoded: %@”, base64Encoded);
Decoding
NSData *nsdataFromBase64String = [[NSData alloc]initWithBase64EncodedString:base64Encoded options:0];
// Decoded NSString from the NSData
NSString *base64Decoded = [[NSString alloc] initWithData:nsdataFromBase64String encoding:NSUTF8StringEncoding];
NSLog(@”Decoded: %@”, base64Decoded);
========================================
Base64 Encode/Decoding an NSData Ob