NSString与Base64转换

	// 转换成base64编码, string明文字符串
	NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
	NSString *stringBase64 = [data base64Encoding]; // base64格式的字符串


	// 由base64转成明文
	NSData *data = [[NSData alloc] initWithBase64EncodedString:stringBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters];
	NSString *string =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];


你可能感兴趣的:(iOS,base64,NSString)