From 4e0d4441bb5613fb09cf772f7bcf7beb15337443 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 22 Aug 2023 16:14:23 +0300 Subject: Genesis commit --- LICENSE | 14 ++++++++++++++ Makefile | 15 +++++++++++++++ README.md | 22 ++++++++++++++++++++++ mkpass | 21 +++++++++++++++++++++ mkpass.1 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100755 mkpass create mode 100644 mkpass.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..276994d --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ +BSD Zero Clause License + +Copyright © 2023 Thomas Voss + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1fb7450 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +.POSIX: + +target = mkpass + +PREFIX = /usr/local/bin +DPREFIX = ${DESTDIR}${PREFIX} + +all: ${target} +${target}: + chmod +x $@ + +install: + mkdir -p ${DPREFIX}/bin ${DPREFIX}/man/man1 + cp ${target} ${DPREFIX}/bin + cp ${target}.1 ${DPREFIX}/man/man1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..790935a --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# mkpass + +`mkpass` is a CLI utility to generate passwords from the command\-line. All +random characters are generated by `/dev/urandom`. + +By default passwords are 64 characters long and may contain any printable ASCII +character. If you would like to specify the password length, you can use the +`-l` command\-line option. If you would like to specify the set of characters +to use in the password, you can provide a set of characters or a range in the +same form as `tr(1)`. + +For example to generate a 40 character long password containing only the numbers +0–9 and the uppercase-characters A–F: + + $ mkpass -l 40 0-9A-F + 379A2E98B2BE03A5F4B2F5AC39F4FD8429B2CAFD + +## Installation + +Installation is easy by using the provided Makefile: + + $ sudo make install diff --git a/mkpass b/mkpass new file mode 100755 index 0000000..d1acc08 --- /dev/null +++ b/mkpass @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +usage() { + echo "Usage: ${0##*/} [-n] [-l length] [chars]" >&2 + exit 1 +} + +while getopts 'l:n' o; do + case "$o" in + l) len="$OPTARG" ;; + n) nnl=false ;; + *) usage ;; + esac +done + +shift $((OPTIND - 1)) +[ $# -gt 1 ] && usage +