iPhone 和 HMAC-SHA-1 编码
我试图打电话给亚马逊网络服务,但我一直在获取签名,看了这个,但我仍然有一个问题。
使用这个例子是什么
NSData *keyData;
NSData *clearTextData
? 我需要为这两个值传递什么?
/*
inputs:
NSData *keyData;
NSData *clearTextData
*/
uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0};
CCHmacContext hmacContext;
CCHmacInit(&hmacContext, kCCHmacAlgSHA1, keyData.bytes, keyData.length);
CCHmacUpdate(&hmacContext, clearTextData.bytes, clearTextData.length);
CCHmacFinal(&hmacContext, digest);
NSData *out = [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我花了大约 4 个小时谷歌搜索并寻找在 iPhone 上计算未加密的 SHA1 的方法,该方法将与 php 中 sha1() 函数的结果相匹配。 结果如下:
希望这能帮助其他在 iPhone 上遇到 SHA1 问题的人
I just spent like 4 hours Googling and looking for ways to calculate an unkeyed SHA1 on the iPhone that would match the results of the sha1() function in php. Here was the result:
Hopefully this will help others who are struggling with SHA1 on the iPhone
如果您也调用亚马逊网络服务来查找价格或产品详细信息,您的亚马逊网络服务密钥将被禁用,您的应用程序将停止工作。
查看亚马逊网络服务的服务条款,严格禁止移动客户端使用:
https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html
当我自己的应用程序在某个应用程序中禁用了我的 AWS 密钥时,我很难发现这一点生产应用程序。 我已经阅读了 TOS,但它实际上并不存在,正如您可以通过上面的链接看到的其他一些模糊的使用细节。 您不会认为联盟计划与 API 有任何关系,但事实确实如此。
您可以在这篇 TechCrunch 文章中找到被阻止的其他应用程序的详细信息:
http://www.techcrunch.com/2009/07/07/amazon-killing-mobile-apps-that-use-its-data/
只是给您一个提示,希望能为您节省大量工作。
If you are calling the Amazon web service too look up prices or product details, your Amazon web service key will be disabled and your app will stop working.
Look at the terms of service of the Amazon Web Services, use by mobile clients is strictly disallowed:
https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html
I found this out the hard way when my own application had my AWS key disabled in a production app. I had read the TOS, but it was not really there as you can see by the link above to some other obscure detail of use. You wouldn't think the affiliate program would have anything to do with the API, but it does.
You can find details of other apps blocked at this TechCrunch article:
http://www.techcrunch.com/2009/07/07/amazon-killing-mobile-apps-that-use-its-data/
Just giving you a heads up and hopefully saving you a lot of work.
查看 CocoaCryptoHashing 了解 SHA1 编码
Take a look at CocoaCryptoHashing for the SHA1 encoding
我在这里发布了一个解决方案,该解决方案返回 Base64 编码数据AWS 要求的。
I posted one solution to this here, that returns the Base64 encoded data that AWS requests.
Apple 的 iOS 开发者库提供了一个名为 CryptoExercise 的优秀示例,其中包含一个简单的函数:
Apple's iOS developer library has provided an excellent sample titled CryptoExercise which includes a simple function:
您可以查看此
也许它对你有帮助。
You can see this
maybe it helps you.