title: How can i convert NSdata to hex string?
body: <p>i tried following codes for converting a NSData to hex string values but all are wrong?</p>
  
  <p>here "result" is my NSdata</p>
  
  <p>i need a hex string as output but iam not getting that </p>
  
  <pre><code>NSUInteger dataLength = [result length];
    NSLog(@"%d",dataLength);
      NSMutableString *string = [NSMutableString stringWithCapacity:dataLength*2];
     const unsigned char *dataBytes = [result bytes];
      for (NSInteger idx = 0; idx &lt; dataLength; ++idx) {        [string appendFormat:@"%02x", dataBytes[idx]];
   }    
      NSLog(@"%@",string);
  </code></pre>
  
  <p>how can i convert this please</p>
  
  <p>UPDATES: the result data contains encrypted string .i want to convert this to hex values</p>