1 | [![Build Status](https://travis-ci.org/rbtdev/node-cmd-bcrypt.svg?branch=v0.0.9)](https://travis-ci.org/rbtdev/node-cmd-bcrypt)
|
2 | #node-cmd-bcrypt
|
3 | A simple utility to hash plaintext arrays or line delimited text files into bcrypt hashes. Provides both
|
4 | a utility for command line use, and a module function for use in your application.
|
5 | The command line utility reads from stdin and outputs to stdout, and includes several options for specifying
|
6 | bcrypt complexity, and inclusion of the plaintext in the output. Easily used as a 'pipe' to process the
|
7 | output of other commands. The function accepts an array of strings, and an options object.
|
8 |
|
9 | ##Usage
|
10 | ###Command Line Utility
|
11 | ```
|
12 | $ npm install -g @rbtdev/node-cmd-bcrypt
|
13 | $ cat password_file.txt | passwdjs -r 12 -p -s "-" > hashmap.txt
|
14 | $ passwdjs --help
|
15 |
|
16 | Usage: index [options]
|
17 |
|
18 | Reads stdin and uses bcrypt to hash each line. Writes hash values to stdout one per line in the same order as the input lines.
|
19 |
|
20 | Options:
|
21 |
|
22 | -h, --help output usage information
|
23 | -V, --version output the version number
|
24 | -r, --rounds <n> Complexity factor for salt generation [10]
|
25 | -p, --plaintext Include plaintext at beginning of line, sepated by ' '
|
26 | -s, --separator <separator> Use as a separator between plaintext and hash [':']
|
27 |
|
28 | Examples:
|
29 |
|
30 | $ cat file.txt | passwdjs -r 10 -p -s " "
|
31 | $ echo "password" | passwdjs -r 15
|
32 |
|
33 | ```
|
34 | ###As a required module
|
35 |
|
36 | ####Installation
|
37 | ```js
|
38 | $ npm install --save @rbtdev/node-cmd-bcrypt
|
39 | ```
|
40 |
|
41 | ```js
|
42 |
|
43 | var passwdjs = require(@rbtdev/node-cmd-bcrypt);
|
44 |
|
45 | var passwords = [
|
46 | 'password1',
|
47 | 'password2',
|
48 | 'password3'
|
49 | ]
|
50 |
|
51 | var opts = {
|
52 | rounds: 12, // rounds to use (complexity). see bcryptjs for details.
|
53 | plaintext: true, // true to include original plaintext at beginning of output line [false]
|
54 | separator: '-' // separator between plaintext and hash in output line [':']
|
55 | };
|
56 |
|
57 | passwdjs(passwords, opts)
|
58 | .on('line', doSomethingWithLine)
|
59 | .on('done', doSomethingWithResultsArray);
|
60 |
|
61 | function doSomethingWithLine (line) {
|
62 | console.log('line =', line);
|
63 | };
|
64 |
|
65 | function doSomethingWithResultsArray (results) {
|
66 | results.forEach(function (result) {
|
67 | console.log('hash =', result);
|
68 | });
|
69 | }
|
70 | ```
|