有人让 CryptoJS 与 Cyber​​source REST API v3 报告签名一起工作吗?

Anyone gotten CryptoJS to work with Cybersource REST API v3 reporting for the Signature?

无法为 Cyber​​source 签名生成正确的 HMAC 256 哈希 headers

我已经为此工作了几天,使用提供的示例代码生成正确的 HMAC 签名,我可以轻松地让它在 .Net 中运行。但是我无法让 CryptoJS 工作,我相信它源于 CryptoJS 在内部将“\n”解释为 LRCF 并因此取消加密的事实。请注意,我仅限于 ECMA5,并将 CryptoJS 作为缩小函数引入。

var data = "host: api.cybersource.com\ndate: Mon, 10 Jun 2019 20:41:05 GMT\n(request-target): get /reporting/v3/report-downloads?organizationId={OrgId}&reportDate=2019-06-06&reportName=PaymentBatchDetailReport\nv-c-merchant-id: {MerchId}";

var hash   = CryptoJS.HmacSHA256(data, "{SecretKey}");
var base64 = CryptoJS.enc.Base64.stringify(hash);
document.write(base64);

如有任何帮助,我们将不胜感激!

确保在将密钥传递给 CryptoJS.HmacSHA256 之前对其进行 Base64 解码。

例如 var words = CryptoJS.enc.Base64.parse({SecretKey}); var hash = CryptoJS.HmacSHA256(data, words);