【发布时间】:2021-01-31 19:51:01
【问题描述】:
在 IBM API Connect 中,我尝试在 IBM API Connect 网关脚本中使用“加密”模块。当我测试gatewascript是否支持加密模块时,我得到如下响应
Gatewayscript 中的代码:
var crypto = require('crypto');
session.output.write(crypto);
输出:
*{
"getHashes": {},
"getCiphers": {},
"createHash": {},
"createHmac": {},
"createSign": {},
"createVerify": {},
"createCipheriv": {},
"createDecipheriv": {},
"randomBytes": {}
}*
但是当我尝试使用它时,我得到了 500 Internal Server Error:
代码:
var crypto = require('crypto');
var key = "Alice";
var hmac = crypto.createHmac('hmac-sha256', key);
var input = "This is plaintext to hash";
var result = hmac.update(input).digest('base64');
session.output.write(result);
输出:
{
"httpCode": "500",
"httpMessage": "Internal Server Error",
"moreInformation": "Internal Error"
}
不知道哪里出了问题。我正在从 IBM 网站复制粘贴确切的示例。这里是对crypto的引用:https://www.ibm.com/support/knowledgecenter/SS9H2Y_7.7.0/com.ibm.dp.doc/crypto_js.html#crypto.createHmac
【问题讨论】:
标签: websphere apiconnect