Created
August 26, 2015 18:53
-
-
Save gavinengel/64ba135020fbd069f1b1 to your computer and use it in GitHub Desktop.
generate a six char password suffix (64bit)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/** | |
* hash the std and in (6) base64 for appending to a password, perhaps yearly | |
* example: base password is `foobarbaz`, and this year's append is: tU68/+, final password is: `foobarbaztU68/+`, | |
* this means you can use a single `base password` | |
* 64^6 = 68,719,476,736 so it makes each password very difficult to "guess" | |
*/ | |
var fs = require('fs') | |
var crypto = require('crypto') | |
var home = process.env['HOME'] | |
var saltPath = home + '/.ssh/id_rsa' | |
var salt = '' | |
var rawSalt = fs.readFileSync(saltPath,'utf8') | |
var hash = '' | |
var out = console.log | |
var target = '' | |
require("copy-paste").global() | |
var pash = require('pash') | |
// get private key (the salt) | |
salts = rawSalt.split(/\n/) | |
salts.forEach(function(each) { | |
if (each.indexOf('-----') === -1) { | |
salt = salt + each | |
} | |
}) | |
// gather passed string to hash | |
target = process.argv.pop() | |
// create hash | |
pash(target, salt, function(raw) { | |
hash = raw.toString('base64').slice(0, 6) | |
// save hash to clipboard | |
copy(hash) | |
out('copied hash for `' + target + '`: ' + hash) | |
process.exit() | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment