此文章是vip文章,如何查看?  

1,点击链接获取密钥 http://nicethemes.cn/product/view29882.html

2,在下方输入文章查看密钥即可立即查看当前vip文章


Mac SHA1加密

  • 时间:
  • 浏览:
  • 来源:互联网


//HMAC_SHA1加密

#include <CommonCrypto/CommonDigest.h>

#include <CommonCrypto/CommonHMAC.h>




//密码加密方式:SHA1

- (NSString *)getHashEncription:(NSString *)key andData:(NSString *)data{

    

    NSLog(@"Secret Key %@ And Data %@", key, data);

    

    constchar *cKey  = [keycStringUsingEncoding:NSUTF8StringEncoding];

    constchar *cData = [datacStringUsingEncoding:NSUTF8StringEncoding];

    

    unsignedchar cHMAC[CC_SHA1_DIGEST_LENGTH];

    

    //HmacSHA256

    

    CCHmac(kCCHmacAlgSHA1, cKey,strlen(cKey), cData, strlen(cData), cHMAC);

    

    NSData *HMAC = [[NSDataalloc] initWithBytes:cHMAC

                                          length:sizeof(cHMAC)];

    

    NSData *base64Data = [HMACbase64EncodedDataWithOptions:0];

    

    NSLog(@"Base 64 encoded = %@",base64Data);

    NSLog(@"NSData Value %@", HMAC);

    

    

    NSLog(@"base64Data11111====%@",[[NSStringalloc] initWithData:base64Dataencoding:NSUTF8StringEncoding]);

    

    return [[NSStringalloc] initWithData:base64Dataencoding:NSUTF8StringEncoding];

    

}


本文链接http://element-ui.cn/news/show-577058.aspx