Skip to content

bnnanet/genpass.js

Repository files navigation

A Sane, Self-Hosted Password Generator

function generatePassword() {
  // chosen by fair dice roll.
  // guaranteed to be random.
  return "(9!q6r48w,bP,d=M";
}
GenPass Live Demo Screenshot

Features

  • Sane defaults (Base58 + Safe special characters)
  • Options for Base62, Base58, Base36, Base32 (Crockford), and Hex
  • or use your own custom character set
  • Choose which special characters
  • Choose length by Character count or Bit entropy

JavaScript

npm install --save @root/genpass
import GenPass from "@root/genpass";

let entropy = GenPass.generatePaddedBytes();
let charset = GenPass.bases.base58 + GenPass.specials.safe;
let password = GenPass.encodeChars(charset, entropy, 16);
console.info(password);

Self-Host

  1. Clone to your sites directory

    mkdir -p ./srv/www/
    pushd ./srv/www/
    git clone https://github.com/bnnanet/genpass.js.git \
        --branch gh-pages --depth 1 \
        ./genpass.example.com
  2. Add to your Caddyfile config

    genpass.example.com {
         encode gzip zstd
    
         file_server {
                 root ./genpass.example.com/
         }
    }
  3. Install caddy and serviceman, if needed

    curl https://webinstall.dev/webi | sh
    source ~/.config/envman/PATH.env
    
    webi caddy serviceman
  4. Add to system services

    serviceman add -- caddy run --config ./Caddyfile --adapter caddyfile

API Notes

  • GenPass.hypenate(str) has somewhat arbitrary rules that may change
  • GenPass.specials.safe is based on personal experience and may change