-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathNSString+HMAC.h
36 lines (29 loc) · 997 Bytes
/
NSString+HMAC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// NSString+HMAC.h
//
// Created by Tyler Neylon on 5/19/11.
//
// Methods for sending authenticated messages; uses SHA256.
// See here for an overview of the purpose of these methods:
// http://en.wikipedia.org/wiki/HMAC
//
// Sample usage:
// NSString *msg = [self createMessage];
// NSString *key = @"a9bk342nziAFD234"; // Private key.
// NSString *hmac = [msg hmacWithKey:key];
// NSString *urlStr = [NSString stringWithFormat:
// @"http://%@/%@?msg=%@&hmac=%@",
// domain, path, msg, hmac];
// Now send a request to urlStr; if the server knows
// the private key, it can recompute the HMAC string, and if they
// match, have confidence that the message originated from someone
// else who knows the private key as well.
//
#import <Foundation/Foundation.h>
@interface NSData (Hexit)
- (NSString *)hexString;
@end
@interface NSString (HMAC)
- (NSString *)hexString;
- (NSString *)hmacWithKey:(NSString *)key;
@end