views:

107

answers:

1

Hi, when i use this code to create a sha256 of a string

unsigned char hashedChars[32];
NSString *inputString;
inputString = [NSString stringWithFormat:@"hello"];
NSData * inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding];
CC_SHA256(inputData.bytes, inputData.length, hashedChars);

it returns the hash correctly, but i need to insert a string like this "\x00\x25\x53" and in this case, the function returns a sha256 of empty string because the specified encoding cannot be used to convert the receiver.

Now, my question is:How to insert this special characters for generate a correct hash? Thanks

A: 

You probably should use NSData instead of NSString then. Where do you get that string from?

Sven
My cycle trasform for example this string "002553" in "\x00\x25\x53" and i would send this bytes to the sha256 function for create the hash, but i have problem with encoding obviously!
pakizip