export const upgradeBase64crypto = (password) => {
crypto.randomBytes(64, (err, buf) => {
const salt = buf.toString("base64");
crypto.pbkdf2(password, salt, 100, 64, "sha512", (err, key) => {
return key.toString("base64");
});
});
};
import { upgradeBase64crypto } from "../../../utils/pwCrypto";
export default {
Mutation: {
signUpUser: async (_, args, { request, query }) => {
try {
const param = args.param;
let pw = upgradeBase64crypto(param.pw);
console.log(pw);
}
catch (err) {}
},
},
};
When running console.log(key.toString('base64'))
in upgradeBase64crypto
, the normally encrypted string appears in the log. However, running return key.toString('base64')
returns undefined
. What's the problem?