iOS之SHA1算法
程序员文章站
2022-05-16 10:21:16
ios之sha1算法。
#import
+ (nsstring *)sha1:(nsstring *)inputstring{
nsdata *data = [inputstring dataus...
ios之sha1算法。
#import
+ (nsstring *)sha1:(nsstring *)inputstring{
nsdata *data = [inputstring datausingencoding:nsutf8stringencoding];
uint8_t digest[cc_sha1_digest_length];
cc_sha1(data.bytes,(unsigned int)data.length,digest);
nsmutablestring *outputstring = [nsmutablestring stringwithcapacity:cc_sha1_digest_length];
for (int i = 0; i < cc_sha1_digest_length; i++) {
[outputstring appendformat:@"%02x",digest[i]];
}
return [outputstring lowercasestring];
}