gpt4 book ai didi

javascript - 如何使用 Javascript 为 AWS 创建签名?

转载 作者:搜寻专家 更新时间:2023-11-01 00:32:12 25 4
gpt4 key购买 nike

我正在尝试使用 Node.js 为 AWS Mechanical Turk 创建签名,但在这样做时遇到了问题。目前我正在使用以下内容,但不断出现错误:

CryptoJS.HmacSHA1(service + operation + timestamp, process.env.SECRET_ACCESS_KEY); 

签名的解释在这个link .它指出要创建一个签名

A request signature, an HMAC, is calculated by concatenating the values of the Service, Operation, and Timestamp parameters, in that order, and then calculating an RFC 2104-compliant HMAC, using the Secret Access Key as the "key." The computed HMAC value should be base64 encoded, and is passed as the value of the Signature request parameter. For more information, go to http://www.faqs.org/rfcs/rfc2104.html.

最佳答案

我认为这对你有用(我使用 GetAccountBalance)作为一个简单的例子:

<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha1.js"></script>  
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script>
<script>
var service = "AWSMechanicalTurkRequester";
var timestamp = new Date().toISOString();
var operation = "GetAccountBalance";
var secret = "YOURSECRETKEY";
var signature = CryptoJS.HmacSHA1(service + operation + timestamp, secret).toString(CryptoJS.enc.Base64);
</script>

关于javascript - 如何使用 Javascript 为 AWS 创建签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26915864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com