开发者

char array to [NSString stringWithFormat:]

开发者 https://www.devze.com 2023-04-01 19:37 出处:网络
I have this code in my code (md5 hashing) unsigned char result[16]; // fill result with data [NSString stringWithFormat:

I have this code in my code (md5 hashing)

unsigned char result[16];
// fill result with data
[NSString stringWithFormat: 
              @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%开发者_如何转开发02x%02x",
              result[0], result[1], result[2], result[3], 
              result[4], result[5], result[6], result[7],
              result[8], result[9], result[10], result[11],
              result[12], result[13], result[14], result[15]
              ];

Is there some faster way, how to push whole array in NSString than this code?


That's the fastest way to hexify 16 characters into an NSString. If you do this often, wrap it up in a function so you only have one copy of the code. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消