bcrypt 852 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env node
  2. var path = require("path"),
  3. bcrypt = require(path.join(__dirname, '..', 'index.js')),
  4. pkg = require(path.join(__dirname, '..', 'package.json'));
  5. if (process.argv.length < 3) {
  6. process.stderr.write([ // No dependencies, so we do it from hand.
  7. "",
  8. " |_ _ _ _ |_",
  9. " |_)(_| \\/|_)|_ v"+pkg['version']+" (c) "+pkg['author'],
  10. " / | "
  11. ].join('\n')+'\n\n'+" Usage: "+path.basename(process.argv[1])+" <input> [rounds|salt]\n");
  12. process.exit(1);
  13. } else {
  14. var salt;
  15. if (process.argv.length > 3) {
  16. salt = process.argv[3];
  17. var rounds = parseInt(salt, 10);
  18. if (rounds == salt)
  19. salt = bcrypt.genSaltSync(rounds);
  20. } else
  21. salt = bcrypt.genSaltSync();
  22. process.stdout.write(bcrypt.hashSync(process.argv[2], salt)+"\n");
  23. }