具有 OpenSSL/请求 Amazon S3 签名的 HMAC-SHA1

发布于 2024-12-09 09:03:16 字数 286 浏览 0 评论 0原文

我正在编写一个程序,使用 libCurl 和 OpenSSL 将文件上传到 C 中的 Amazon S3。要向亚马逊发送请求,我必须使用 HMAC-SHA1 这里亚马逊文档对此进行了解释。请帮忙,可以用 openSSL 来完成吗?如果你知道,请告诉我如何做?或者我需要使用其他库?

I am writing a program to upload file to Amazon S3 in C with libCurl and OpenSSL. To send a request to amazon I have to sign it - with HMAC-SHA1 here amazon doc that explain it. Help, please, can it be done with openSSL, and if U know advise how? Or I need to use some other libs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑红尘 2024-12-16 09:03:16

文档的这一部分准确解释了每种请求类型(包括上传文件)要编码的内容,并提供了几个有助于测试请求/哈希的示例:
http://docs.aws.amazon.com/AmazonS3/latest /dev/RESTAuthentication.html#RESTAuthenticationExamples

This section of the documentation explains exactly what to encode for each request type (including uploading a file), with several examples that are good for testing your requests/hashing:
http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationExamples

原谅过去的我 2024-12-16 09:03:16

如果是iOS的话..

AmazonAuthUtils.h

/**
 * Compute a keyed hash of some data with a specified key and algorithm.
 * @param data  The data to sign
 * @param key   The key to sign the data with
 * @param algorithm Which HMAC algortithm to use. Currently support <code>kCCHmacAlgSHA1</code> and <code>kCCHmacAlgSHA256</code>.
 * @return Base64 encoded string that is the signature of the data with the specified key.
 */
+(NSString *)HMACSign:(NSData *)data withKey:(NSString *)key usingAlgorithm:(CCHmacAlgorithm)algorithm;

If it's iOS..

AmazonAuthUtils.h

/**
 * Compute a keyed hash of some data with a specified key and algorithm.
 * @param data  The data to sign
 * @param key   The key to sign the data with
 * @param algorithm Which HMAC algortithm to use. Currently support <code>kCCHmacAlgSHA1</code> and <code>kCCHmacAlgSHA256</code>.
 * @return Base64 encoded string that is the signature of the data with the specified key.
 */
+(NSString *)HMACSign:(NSData *)data withKey:(NSString *)key usingAlgorithm:(CCHmacAlgorithm)algorithm;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文