美文网首页
SHA1加密

SHA1加密

作者: LLL_0901 | 来源:发表于2016-05-03 15:30 被阅读39次

.h

+ (NSString *) sha1:(NSString *)input;


.m

// 需要import<CommonCrypto/CommonDigest.h>

+ (NSString *) sha1:(NSString *)input

{

const char *cstr = [input cStringUsingEncoding:NSUTF8StringEncoding];

NSData *data = [NSData dataWithBytes:cstr length:input.length];

uint8_t digest[CC_SHA1_DIGEST_LENGTH];

CC_SHA1(data.bytes, data.length, digest);

NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];

for(int i=0; i

相关文章

网友评论

      本文标题:SHA1加密

      本文链接:https://www.haomeiwen.com/subject/ottrrttx.html