开发者

NSString is NULL [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

hiiii freinds please any guys say me why str is NULL i will be creasy

NSString *strData = @"issam  bey"   ;

NSMutableData *objNSData = [NSMutableData dataWithData:[strData dataUsingEncoding:NSISOLatin1StringEncoding]];


objNSData = [objNSData EncryptAES:@"12345678901234561234567890123456"];
//NSString* decryptedStr = [[NSString alloc] initWithData:objNSData encoding:NSASCIIStringEncoding];

NSString *str=[[NSString alloc] initWithData: ob开发者_运维技巧jNSData encoding:NSUTF8StringEncoding];

NSLog(@"%@",str);


If you are doing encryption and decryption then read Encrypting / Decrypting / Base64 Encode / Decode in iPhone Objective-C.

For AES256 encryption-decryption, read Adding methods to NSData and NSString using categories to provide AES256 encryption on iOS.


NSString's initWithData:encoding: will try to use the specified data to create a string using the encoding you tell it to use. If it can't do that then it will return nil.

The fact that you tried a different encoding and got a value instead of nil should tell you what's wrong - your encoded data can't be represented by a UTF-8 string but can be represented by a Latin-1 string.

Just out of interest, why do you want to encrypt the data and then view it as a string again?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜