Kim Mỹ
Kim Mỹ

Reputation: 434

How do I convert NSString of base64 string into NSSData

My current code is like below which is from UTF8 to data. But the string is base64 (read from a file to be encrypted in aes256 cbc) and not able to be converted into UTF8

NSString* str = @"somelongbase64stringreadfromsmallimagefile";

NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];

NSMutableData * buffer = [[NSMutableData alloc] initWithLength:[data length] + kCCBlockSizeAES128];

Upvotes: 0

Views: 56

Answers (1)

Kim Mỹ
Kim Mỹ

Reputation: 434

got it working by

NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:0];

Upvotes: 0

Related Questions