Generate SHA256 hash in Objective-C
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I need to generate a Sha256 password in Objective-C, and can't figure out for the life of me how to do it! Is there something easy I'm just missing? I've tried implementing the following method (which was written for iPhone, but I figured maybe it'd work cross-platform, as some Objective-C code does) -(NSString*)sha256HashFor:(NSString*)input { const char* str = [input UTF8String]; unsigned char result[CC_SHA256_DIGEST_LENGTH]; CC_SHA256(str, strlen(str), result); NSMutableString *ret = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST