Added script to generate password hashes.
This commit is contained in:
parent
62df108999
commit
bc304d9bfa
3 changed files with 48 additions and 1 deletions
bin
24
bin/bcrypt.js
Executable file
24
bin/bcrypt.js
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
const saltRounds = 10;
|
||||
|
||||
const stdout = process.stdout
|
||||
const stdin = process.stdin
|
||||
|
||||
let password = '';
|
||||
|
||||
stdin.on('readable', () => {
|
||||
let chunk;
|
||||
while ((chunk = stdin.read()) !== null) {
|
||||
password += chunk;
|
||||
}
|
||||
});
|
||||
|
||||
process.stdin.on('end', () => {
|
||||
if (password[password.length - 1] === '\n') {
|
||||
password = password.substring(0, password.length - 1);
|
||||
}
|
||||
const hash = bcrypt.hashSync(password, saltRounds);
|
||||
stdout.write(`${hash}\n`);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue