NSData to display as a string

Posted by topace on Stack Overflow See other posts from Stack Overflow or by topace
Published on 2010-04-16T13:38:30Z Indexed on 2010/04/16 13:43 UTC
Read the original article Hit count: 297

Filed under:
|
|

Hello all, this is my first post. I am building an iPhone app and stuck with the following:

unsigned char hashedChars[32];
CC_SHA256([inputString UTF8String], [inputString lengthOfBytesUsingEncoding:NSASCIIStringEncoding], hashedChars);
NSData *hashedData = [NSData dataWithBytes:hashedChars length:32];
NSLog(@"hashedData = %@", hashedData);

The log is showing like:

hashedData = <abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh>

But what I need is to convert hashedData into NSString that looks like:

NSString *someString = @"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh";

So basically the string needs to be like hashedData except I don't want the angle brackets and spaces in between.

Any help is much appreciated.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsdata