Browse Source

Added password hash generator

Sotaro KARASAWA 11 years ago
parent
commit
eba54c4fa9
2 changed files with 27 additions and 1 deletions
  1. 25 0
      bin/password-hash-generator.js
  2. 2 1
      package.json

+ 25 - 0
bin/password-hash-generator.js

@@ -0,0 +1,25 @@
+var crypto = require('crypto')
+  , cli = require('cli')
+  ;
+
+function generatePassword (seed, password) {
+  var hasher = crypto.createHash('sha256');
+  hasher.update(seed + password);
+
+  cli.debug("seed is: " + seed);
+  cli.debug("password is: " + password);
+  return hasher.digest('hex');
+}
+
+cli.parse({
+    seed:      [false, 'Password seed', 'string', ''],
+    password:  [false, 'Password raw string', 'string'],
+});
+
+cli.main(function(args, options)
+{
+  console.log("args", args);
+  console.log("options", options);
+
+  this.output(generatePassword(options.seed, options.password) + '\n');
+});

+ 2 - 1
package.json

@@ -43,7 +43,8 @@
     "grunt-sass": "~0.14.1",
     "reveal.js": "~2.6.2",
     "grunt-cli": "~0.1.13",
-    "bower": "~1.3.9"
+    "bower": "~1.3.9",
+    "cli": "~0.6.4"
   },
   "devDependencies": {},
   "license": [