src/services/crypto.js
/**
   * Create a password hash
   * @method createPasswordHash
   * @param {string|Buffer} buffer - The string or buffer.
   * @returns {Object} Object that contains the hash and salt.
   */
Create a password hash
@method createPasswordHash
@param {string|Buffer} buffer - The string or buffer.
@returns {Object} Object that contains the hash and salt.
Create a password hash @method createPasswordHash @param { string|Buffer } buffer - The string or buffer . @returns { Object } Object that contains the hash and salt .
createPasswordHash(password, salt) {
    const generatedSalt = salt || randomBytes(128).toString('base64');
    const hmac = createHmac('sha256', generatedSalt);
    hmac.update(password);
    let hashedPassword = hmac.digest('hex');
    const scrypt = scryptSync(hashedPassword, generatedSalt, 64);
    hashedPassword = scrypt.toString('hex');
    return {
      hash: hashedPassword,
      salt: generatedSalt
    };
  }
createPasswordHash ( password , salt ) { const generatedSalt = salt || randomBytes ( 128 ) . toString ( 'base64' ) ; const hmac = createHmac ( 'sha256' , generatedSalt ) ; hmac . update ( password ) ; let hashedPassword = hmac . digest ( 'hex' ) ; const scrypt = scryptSync ( hashedPassword , generatedSalt , 64 ) ; hashedPassword = scrypt . toString ( 'hex' ) ; return { hash : hashedPassword , salt : generatedSalt } ; }
Create a password hash
 @method createPasswordHash
 @param {string|Buffer} buffer - The string or buffer.
Create a password hash @method createPasswordHash @param { string|Buffer } buffer - The string or buffer .