我一直在使用在亚马逊论坛上找到的文件。这是线程:
https ://forums.aws.amazon.com/message.jspa?messageID=147377
它使用一个 .wsc 文件,它只是一个 JScript 文件,它定义了可以在 ASP 代码中使用的对象。像这样:
' ### be sure to have sha256.wsc in the same folder as this script
Dim sha256
Set sha256 = GetObject( "script:" & Server.MapPath("sha256.wsc") )
sha256.hexcase = 0
Dim result
result = sha256.b64_hmac_sha256( secretkey, stringtosign )
这是一个最初用于签署对 Amazon API 的请求的文件。由于我不明白的原因,这在 .wsc 文件中包含了这行代码:
d=d.replace ( /\s/g, "\n");
这会将所有空白字符(包括空格)转换为“\n”。很难相信空格需要转换为“\n”。无论如何,我必须注释掉这一行以使代码为我工作!它确实有效。我已经使用了一段时间没有问题。
从 sha256.wsc 文件:
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
* Adapted into a WSC for use in classic ASP by Daniel O'Malley
* (based on an SHA-1 example by Erik Oosterwaal)
* for use with the Amazon Product Advertising API
*/
sha256.wsc 文件的直接链接:
https ://forums.aws.amazon.com/servlet/JiveServlet/download/9-34858-139271-2601/sha256.wsc
我一直找不到官方下载站点。