I want to use pbkdf2Sync method to encrypt password. My nodejs version is 0.12.7. By default, there should be crypto module with pbkdf2Sync method or randomBytes, but occurs TypeError: Object # has no method 'pbkdf2Sync'. I have tried also npm install crypto, but it doesn't help. It looks like crypto module doesn't exist.
Snippet code of my User model:
var crypto = require('crypto');
UserSchema.methods.setPassword = function (password) {
this.salt = crypto.randomBytes(16).toString('hex');
this.hash = crypto.pbkdf2Sync(password, this.salt, 1000, 64).toString('hex');
};
Solutions from similar topic don't work.