npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rbtdev/node-cmd-bcrypt

v1.2.12

Published

A simple bycryptjs based command line password hasher

Downloads

47

Readme

npm version Build Status Coverage Status

node-cmd-bcrypt

A simple utility to hash plaintext arrays or line delimited text files into bcrypt hashes. Provides both a utility for command line use, and a module function for use in your application. The command line utility reads from stdin and outputs to stdout, and includes several options for specifying bcrypt complexity, and inclusion of the plaintext in the output. Easily used as a 'pipe' to process the output of other commands. The function accepts an array of strings and an options object.

Usage

Command Line Utility

$ npm install -g @rbtdev/node-cmd-bcrypt

$ passwdjs --help
  Usage: passwdjs <cmd>


  Commands:

    hash [options] [passwords...]  Uses bcryptjs to hash each password provided or reads lines from stdin if no passwords are provided.

  Command line tool to hash and compare bcrypt passwords.

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

  Examples:

    $ passwdjs hash -j -r 12 password1 password2 password3 
    {
      "$2a$12$QHEdi2VK9HhipSs9rVfQYOS0FwKnjxoL/1mhqkD67lZJ0luPhWX1u": "password1",
      "$2a$12$5pHzuObUEE5wSEOWBIayEe1Uv1RIRXpPVTxaKIXpW07t9fBrBJnWO": "password2",
      "$2a$12$H5eV9qwx82rZeQ8PbYaKW.Unc8uiz2LrvgLmCStdY9EFIiC44lxem": "password3",
    }

    $ cat passwords.txt
    password1
    password2
    password3
    password4
    password5

    $ cat passwords.txt | passwdjs hash -r 12 -j
    {
      "$2a$12$ErsnLyXSXaupErd5imARB.S6sl6QD8m0a.Z0ECGA5KsqiEVJs80W2": "password1",
      "$2a$12$6k/WRP17ba/XfewrzpOz5OJIIbiz12ocHbDJvRpk.USFTioUCnOem": "password2",
      "$2a$12$hkelc1Xu.jFq3UpRmidpCOvZcUEWIpKks0ZewkmArjLSxnCwhoDJ2": "password3",
      "$2a$12$WK1KVKmiH.heNTpUwR2IcuXyzCjrO64Nun/A5R11DavKcc48h0Epu": "password4",
      "$2a$12$86N8t.Ha/RbhM.VYaFJI6uUbZI3g8f93A2pmWz7AAReZ8aAYQm2KO": "password5"
    }

    $ passwdjs hash -r 12 -j -f passwords.txt
    {
      "$2a$12$ErsnLyXSXaupErd5imARB.S6sl6QD8m0a.Z0ECGA5KsqiEVJs80W2": "password1",
      "$2a$12$6k/WRP17ba/XfewrzpOz5OJIIbiz12ocHbDJvRpk.USFTioUCnOem": "password2",
      "$2a$12$hkelc1Xu.jFq3UpRmidpCOvZcUEWIpKks0ZewkmArjLSxnCwhoDJ2": "password3",
      "$2a$12$WK1KVKmiH.heNTpUwR2IcuXyzCjrO64Nun/A5R11DavKcc48h0Epu": "password4",
      "$2a$12$86N8t.Ha/RbhM.VYaFJI6uUbZI3g8f93A2pmWz7AAReZ8aAYQm2KO": "password5"
    }

    $ echo "password" | passwdjs hash -r 15
    $2a$15$mT4C4CHQuTcumZG74JlGhen2e.b9yAWVtIFREq9Pge6dDXUkHiZPG

As a required module

Installation

$ npm install --save @rbtdev/node-cmd-bcrypt
Hash an array of passwords, and return results in an object
var passwdjs = require('@rbtdev/node-cmd-bcrypt');

var passwords = [
    'password1',
    'password2',
    'password3'
]

var opts = {
    rounds: 12, // rounds to use (complexity).  see bcryptjs for details. 
    json: true, // true to output JSON object with hashes and passwords
};

/**
 * Hash array of passwords, result in object
 */
passwdjs(passwords, opts)
    .on('line', doSomethingWithLine)
    .on('done', doSomethingWithResultsObj)
    .on('error', doSomethingWithError)

function doSomethingWithLine(line) {
    console.log('line =', line);
};

function doSomethingWithResultsObj(results) {
    for (var hash in results) {
        var plaintext = results[hash]
        console.log("the bcrypt hash for " + plaintext + " is " + hash);
    };
}

function doSomethingWithError(err) {
    console.log(err);
}
Hash a file of passwords (one per line) and return results in an array
var passwdjs = require('@rbtdev/node-cmd-bcrypt');

var opts = {
    rounds: 12, // rounds to use (complexity).  see bcryptjs for details. 
};

/**
 * Hash file of passwords, result in array
 */
passwdjs('test/test.txt', opts)
    .on('line', doSomethingWithLine)
    .on('done', doSomethingWithResultsArray)
    .on('error', doSomethingWithError)


function doSomethingWithLine(line) {
    console.log('line =', line);
};

function doSomethingWithResultsArray(results) {
    results.forEach(function (result) {
        console.log("Hash = " + result);
    })
}

function doSomethingWithError(err) {
    console.log(err);
}
Hash a file of passwords (one per line) and return results in an object
var passwdjs = require('@rbtdev/node-cmd-bcrypt');

var opts = {
    rounds: 12, // rounds to use (complexity).  see bcryptjs for details. 
    json: true, // true to output JSON object with hashes and passwords
};

/**
 * Hash file of passwords, result in object
 */
passwdjs('test/test.txt', opts)
    .on('line', doSomethingWithLine)
    .on('done', doSomethingWithResultsObj)
    .on('error', doSomethingWithError)

function doSomethingWithLine(line) {
    console.log('line =', line);
};

function doSomethingWithResultsObj(results) {
    for (var hash in results) {
        var plaintext = results[hash]
        console.log("the bcrypt hash for " + plaintext + " is " + hash);
    };
}

function doSomethingWithError(err) {
    console.log(err);
}