views:

169

answers:

1

*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

A: 

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.

Tom