// // BloggenAWSUtilities.m // Bloggen // // Created by Davis Remmel on 2/15/14. // Copyright (c) 2014 Davis Remmel. All rights reserved. // // These functions are needed to generate an AWS signature, and to sign // the request. #import "BloggenAWSUtilities.h" #import @implementation BloggenAWSUtilities + (NSData *)hmacSHA1WithDigestKey:(NSData *)key stringToEncode:(NSString *)inputString { NSData *inputStringData = [inputString dataUsingEncoding:NSUTF8StringEncoding]; unsigned int digestLength = 20; // SHA-1 has a length of 160-bits (20-bytes) unsigned char digest[digestLength]; CCHmac(kCCHmacAlgSHA1, [key bytes], [key length], [inputStringData bytes], [inputStringData length], digest); NSData *digestData = [[NSData alloc] initWithBytes:digest length:digestLength]; return digestData; } @end