我正在我当前的应用程序中实现河豚算法,我得到了错误
#import "NSData+Base64Utilities.h"
我必须添加哪个框架或文件才能消除此错误?
我正在使用以下代码,我是否遵循正确的方法?
define PADDING_PHRASE @" "
import "CryptoUtilities.h"
import "blowfish.h"
import "NSData+Base64Utilities.h"
@implementation CryptoUtilities
+ (NSString *)blowfishEncrypt:(NSData *)messageData usingKey:(NSData *)secretKey
{
NSMutableData *dataToEncrypt = [messageData mutableCopy];
NSMutableData *emptyData = [[PADDING_PHRASE dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
emptyData.length = 8 - [dataToEncrypt length] % 8;
// Here we have data ready to encipher
[dataToEncrypt appendData:emptyData];
BLOWFISH_CTX ctx;
Blowfish_Init (&ctx, (unsigned char*)[secretKey bytes], [secretKey length]);
NSRange aLeftRange, aRightRange;
NSData *aLeftBox, *aRightBox;
unsigned long dl = 0, dr = 0;
for (int i = 0; i < [dataToEncrypt length]; i += 8) { // Divide data into octets...
// …and then into quartets
aLeftRange = NSMakeRange(i, 4);
aRightRange = NSMakeRange(i + 4, 4);
aLeftBox = [dataToEncrypt subdataWithRange:aLeftRange];
aRightBox = [dataToEncrypt subdataWithRange:aRightRange];
// Convert bytes into unsigned long
[aLeftBox getBytes:&dl length:sizeof(unsigned long)];
[aRightBox getBytes:&dr length:sizeof(unsigned long)];
// Encipher
Blowfish_Encrypt(&ctx, &dl, &dr);
// Put bytes back
[dataToEncrypt replaceBytesInRange:aLeftRange withBytes:&dl];
[dataToEncrypt replaceBytesInRange:aRightRange withBytes:&dr];
}
return [dataToEncrypt getBase64String];
}