开发者

NSData to NSString by changing the value null is returned. I need your help

开发者 https://www.devze.com 2022-12-25 21:09 出处:网络
*cipher.h, cipher.m all code : http://watchitlater.com/blog/2010/02/java-and-iphone-aes-interoperability

*cipher.h, cipher.m all code : http://watchitlater.com/blog/2010/02/java-and-iphone-aes-interoperability

Cipher.m

-(NSData *)encrypt:(NSData *)plainText{
 return [self transform:KCCEncrypt data:plainText;
}

step1.

Cipher *cipher = [[Cipher alloc]initWithKey:@"1234567890"];

NSData *input = [@"kevin" dataUsingEncoding:NSUTF8StringEncoding];

NSData *data = [cipher encrypt:input];开发者_运维技巧

data variables NSLog print : <4d1c4d7f 1592718c fd588cec 84053e35>

step2.

NSString *changeVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

data variables NSLog print : null

NSData to NSString by changing the value null is returned. By converting NSString NSURLConnection want to transfer. I need you help


Kevin, I actually take the result of the cipher encrypt method and use an extension to NSData to convert it to a Base64 encoded string. The cipher text does NOT convert to a valid UTF8 string by itself.

0

精彩评论

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