kSecRandomDefault 未找到?
我在 Mac OS 10.7 上使用 CommonCrypto 进行加密。这个框架不是内置的吗?当我生成随机数据时:
+ (NSData *)randomDataOfLength:(size_t)length {
NSMutableData *data = [NSMutableData dataWithLength:length];
int result = SecRandomCopyBytes(kSecRandomDefault,
length,
data.mutableBytes);
NSAssert(result == 0, @"Unable to generate random bytes: %d",
errno);
return data;
}
我收到错误使用未声明的标识符 kSecRandomDefault,我相信它是在 CommonCrypto 中声明的。
谢谢,非常感谢所有帮助。
I am using CommonCrypto for encryption on Mac OS 10.7. Isn't this framework built in? When I am generating random data:
+ (NSData *)randomDataOfLength:(size_t)length {
NSMutableData *data = [NSMutableData dataWithLength:length];
int result = SecRandomCopyBytes(kSecRandomDefault,
length,
data.mutableBytes);
NSAssert(result == 0, @"Unable to generate random bytes: %d",
errno);
return data;
}
I get the error use of undeclared identifier kSecRandomDefault, which I believe is declared in CommonCrypto.
Thanks, all help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它在 SecRandom.h 中定义。确保您已在项目中包含
Security
框架并添加适当的头文件。它不包含在框架默认标头中(我不确定这是一个过度站点还是故意的)。因此,将以下导入添加到您的实现文件中:It's defined in
SecRandom.h
. Make sure you've included theSecurity
framework in your project and add the appropriate header file. It's not included with the framework default headers (I'm not sure if that's an over site or intentional). So, add the following import to your implementation file: