【发布时间】:2019-09-03 07:34:30
【问题描述】:
我有一个小加密文件,它在一些输入后添加了一个加密的随机数:
const crypto = require("crypto");
module.exports = function (x, y) {
crypto.randomBytes(5, async function(err, data) {
var addition = await data.toString("hex");
return (x + y + addition);
})
}
当我将它导出到另一个文件并控制台记录它时,返回的值是未定义的
const encryption = require('./encryption')
console.log(encryption("1", "2"));
我在这里做错了什么?
我也试过了
module.exports = function (x, y) {
var addition;
crypto.randomBytes(5, function(err, data) {
addition = data.toString("hex");
})
return (x + y + addition);
}
运气不好。
提前致谢。
【问题讨论】:
标签: javascript node.js node-modules module-export