博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS之SHA1算法
阅读量:4289 次
发布时间:2019-05-27

本文共 587 字,大约阅读时间需要 1 分钟。

参考:http://www.jianshu.com/p/8bc791ec42b6

http://www.cnblogs.com/scu-cjx/p/6878853.html

#import <CommonCrypto/CommonDigest.h>

//SHA1加密方式

+(NSString*)sha1WithStr:(NSString *)str

{

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

    NSData *data = [NSData dataWithBytes:cstr length: strlen(cstr)];

    

    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 < CC_SHA1_DIGEST_LENGTH; i++)

        [output appendFormat:@"%02x", digest[i]];

    

    return output;

}

你可能感兴趣的文章
netty源码分析之-服务端启动核心源码分析(5)
查看>>
Storm并行度和流分组详解
查看>>
缓存数据预热详解
查看>>
热点数据降级详解(storm+nginx+lua)
查看>>
加载更多功能实现
查看>>
React相关Dom约束性和非约束性操作
查看>>
Hystrix高可用架构介绍
查看>>
netty源码分析之-SimpleChannelInboundHandler与ChannelInboundHandlerAdapter详解(6)
查看>>
netty源码分析之-开发过程中重要事项分析(7)
查看>>
Sublime Text3插件详解
查看>>
netty源码分析之-ByteBuf详解(8)
查看>>
javascript函数定义三种方式详解
查看>>
javascript中this关键字详解
查看>>
javascript关于call与apply方法详解
查看>>
netty源码分析之-ReferenceCounted详解(9)
查看>>
javascript闭包详解
查看>>
javascript类的创建与实例对象
查看>>
javascript原型详解(1)
查看>>
netty源码分析之-处理器详解(9)
查看>>
javascript原型对象存在的问题(3)
查看>>