I have a little encryption file that adds a encrypted random number after some inputs:
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);
})
}
The returned value is undefined when I export it to another file and console.log it
const encryption = require('./encryption')
console.log(encryption("1", "2"));
What did I do wrong here?
I also have tried
module.exports = function (x, y) {
var addition;
crypto.randomBytes(5, function(err, data) {
addition = data.toString("hex");
})
return (x + y + addition);
}
No luck.
Thanks in advance.