gen_admin_pass.js 554B

12345678910111213141516171819202122232425
  1. /* Admin password encryption */
  2. var minimist = require('minimist')(process.argv.slice(2));
  3. var bcrypt = require('bcryptjs');
  4. var rounds = 10;
  5. if (minimist.r || minimist.rounds)
  6. rounds = parseInt(minimist.r);
  7. if (minimist.i || minimist.in)
  8. generateHash(rounds, minimist.i);
  9. else {
  10. console.error("NO INPUT SUPPLIED!");
  11. }
  12. function generateHash(rounds, text) {
  13. console.log("Hashing with " + rounds + " rounds");
  14. var salt = bcrypt.genSaltSync(rounds);
  15. var hash = bcrypt.hashSync(text, salt);
  16. console.log("HASH: " + hash);
  17. }