Suppose you have two users with the same passwords. For now, the function returns the same hash for the given passwords. Change it, so the hashes are different for each password. Once you write code for generating salt, don't forget to include it in the crypto.scrypt() method.
Computer scienceBackendNode.jsCore ConceptsInternal modulesOther modulesHashing: overviewHash function
Intro to crypto module
Create salt
Report a typo
Sample Input 1:
Sample Output 1:
Hashes are uniqueWrite a program in JavaScript
const crypto = require('crypto');
const password1 = 'joe123';
const password2 = 'joe123';
const createHash = (password) => {
return new Promise((resolve, reject) => {
const salt = /* write your code here */
crypto.scrypt(password, 'yourSalt', 64, (err, result) => {
if (err) {
reject(err);
}
resolve(result.toString('hex'));
});
});
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.