I am using the code found at http://pastie.org/966473 to encrypt/decrypt strings using AES in Objective-C (for iPhone).
I placed the two methods in a file called AES.m. The AES.h looks like:
#import <Foundation/Foundation.h>
@interface AES : NSObject
@end
I am trying to call the encrypt method like this:
NSString *strData = txtText.text;
NSMutableData *objNSData = [NSMutableData dataWithData:[strData dataUsingEncoding:NSUTF16StringEncoding]];
AES *myScript = [[AES alloc] init];
objNSData = [myScript EncryptAES:txtPassword.text];
strData = [[NSString alloc] initWithData:objNSData encoding:NSUTF16StringEncoding];
NSLog(@"%@",[objNSData description]);
But it doesn’t work. It says it can’t find the method. I did try importing both AES.h and AES.m, but no luck.
Add
- (NSMutableData*) EncryptAES: (NSString *) key;to your AES.h file between@implementationand@end.