var bcrypt = require('bcryptjs');

/**
 * Hash a password
 *
 * @param {string} string Password
 * @param {number} [saltRound = 10] Salt round
 * @return {string} Password
 *
 * @example
 * var snu = require('s-node-utils');
 *
 * snu.password.hash("F@3Ltv{>=q[8T%,", 10);
 * //=> $2a$10$OOJ2FlB56wSEhtwvVQxub.hoiWcEzcFsX2ERdNBo3fSXPSoSPK8zW (exemple)
 */
module.exports = function(string, saltRound = 10) {
  var salt = bcrypt.genSaltSync(saltRound);
  var hash = bcrypt.hashSync(string, salt);
  return hash;
};
