i tried following codes for converting a NSData to hex string values but all are wrong?

here "result" is my NSdata

i need a hex string as output but iam not getting that 

```
NSUInteger dataLength = [result length];
  NSLog(@"%d",dataLength);
    NSMutableString *string = [NSMutableString stringWithCapacity:dataLength*2];
   const unsigned char *dataBytes = [result bytes];
    for (NSInteger idx = 0; idx < dataLength; ++idx) {        [string appendFormat:@"%02x", dataBytes[idx]];
 }    
    NSLog(@"%@",string);

```

how can i convert this please

UPDATES: the result data contains encrypted string .i want to convert this to hex values