//
//  VKDes3Handle.m
//  VKCheckInArtifact
//
//  Created by 程石亮 on 2017/11/25.
//  Copyright © 2017年 Facebook. All rights reserved.
//

#import "VKDes3Handle.h"
#include "GTMBase64.h"
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
@implementation VKDes3Handle
+ (NSString *)hmacsha1:(NSString *)text key:(NSString *)secret {//HMAC_SHA1加密算法
  NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];
  NSData *clearTextData = [text dataUsingEncoding:NSUTF8StringEncoding];
  unsigned char result[20];
  CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], result);
  char base64Result[32];
  size_t theResultLength = 32;
  Base64EncodeData(result, 20, base64Result, &theResultLength,YES);
  NSData *theData = [NSData dataWithBytes:base64Result length:theResultLength];
  NSString *base64EncodedResult = [[NSString alloc] initWithData:theData encoding:NSASCIIStringEncoding];
  return base64EncodedResult;
}
@end
