|
本帖最后由 chen462575650 于 2021-4-11 21:17 编辑
各位老板请教一下,我在doeker中run了node-red,使用cryptojs HmacSHA256加密方法undefined。我使用了以下两种方式,----------------------
方法一:
settings.js文件
functionGlobalContext: {
require:require
},
function使用
var CryptoJS = require("crypto-js");
var ts = Math.floor(Date.now() / 1000)
var source = "lennyguotest"
var signStr = "x-timestamp: " + ts + "\nx-source: " + source
var auth = CryptoJS.HmacSHA256(signStr, appKey).toString()
报错
"TypeError: Cannot read property 'HmacSHA256' of undefined"
--------------------
方法二:
修改settings.js文件
functionGlobalContext: {
cryptojs:require('crypto-js')
},
function使用:
var CryptoJS = context.global.cryptojs;
var ts = Math.floor(Date.now() / 1000)
var source = "lennyguotest"
var signStr = "x-timestamp: " + ts + "\nx-source: " + source
var auth = CryptoJS.HmacSHA256(signStr, appKey).toString()
报错与上面一样
--------------------
有老板遇到求解答一下?
|
|