I need to encrypt a string. The service that I am sending it to requires that it be an MD5 hash of the byte array of the string in UTF16LE.
Basically: if I have myString
that needs to be put into a UTF16LE byte array, and then that array needs to be MD5 Hashed.
Does NSUTF16LittleEndianStringEncoding actually make the byte array? I can't tell from the documentation if that's what is going on.
If it does not, does anyone have a good way to create a byte array form a sting with UTF16LE encoding?
I've tried using getBytes
, and [myString bytes] and const char
and I still am striking out. Admittedly there is something I don't understand but the documentation @dev.apple is not shedding any light that I can see.
Note: I asked a similar question the other day but I have since found out more information about what they want.
Thanks
it will when you use it with -[NSString dataUsingEncoding:]
:
NSData * data = [string dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
const char* const bytes = data.bytes;