我坚持这种方法而且我不知道为什么! 谁能指点我一些源代码? 非常感谢! 这是我的源代码:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
.......
readData = [readFileHandle readDataOfLength:defaultLen]
NSData *decryptedData = nil;
//check is last buffer of file
NSUInteger exLen = [readData length] % 16;
NSUInteger decryptionLen = [readData length] - exLen;
NSData *dataForDecryption = nil;
if(exLen != 0)
{
stuck at here-> [readData getBytes:dataForDecryption length:decryptionLen];
//
decryptedData = [dataForDecryption AES256DecryptWithKey:KEY];
self.isEndOfFile = YES;
}
else
decryptedData = [readData AES256DecryptWithKey:KEY];
[readFileHandle closeFile];
.......
[pool drain];
我使用了一些功能,例如:
NSData *dataForDecryption = [[[NSData alloc] initWithBytes:readData length:decryptionLen]autorelease];
NSData *dataForDecryption = [NSData dataWithBytes:readData length:decryptionLen];
但我得到同样的错误。
当我使用时
dataForDecryption = [readFileHandle readDataOfLength:decryptionLen];
虽然它不是EOF,但它在上面的位置停留并且读取的大小为0。
由于
答案 0 :(得分:0)
stuck at here-> [readData getBytes:dataForDecryption length:decryptionLen];
您正在传递dataForDecryption
NSData*
,但参数应该是缓冲区,即void*
。如果您想要NSData*
,则应使用subdataWithRange:
等方法。
dataForEncryption = [readData subdataWithRange:NSRangeMake(0, decryptionLen)];